java8 LocalDateTime
2020-12-28 19:35
标签:toe 获取 system mic lda bsp simple lis soft 在多并发情况下使用SimpleDateFormat需格外注意 :SimpleDateFormat除了format是线程不安全以外,parse方法也是线程不安全的。 LocalDate 只获取年月日 获取年、月、日、星期几 LocalTime 只获取时分秒 获取时分秒 LocalDateTime Instant 获取秒数、获取毫秒数 java8 LocalDateTime 标签:toe 获取 system mic lda bsp simple lis soft 原文地址:https://www.cnblogs.com/zxg-6/p/13028218.htmlLocalDate localDate = LocalDate.now(); //localDate:2020-06-01
LocalDate localDate1 = LocalDate.of(2020, 01, 01); //localDate1:2020-01-01int year = localDate.getYear(); //2020
int year1 = localDate.get(ChronoField.YEAR); //2020
Month month = localDate.getMonth(); //JUNE
int month1 = localDate.get(ChronoField.MONTH_OF_YEAR); //6
int day = localDate.getDayOfMonth(); //1
int day1 = localDate.get(ChronoField.DAY_OF_MONTH); //1
DayOfWeek dayOfWeek = localDate.getDayOfWeek(); //MONDAY
int dayOfWeek1 = localDate.get(ChronoField.DAY_OF_WEEK); //1
LocalTime localTime = LocalTime.of(23, 11, 11); //23:11:11
LocalTime localTime1 = LocalTime.now(); //23:15:51.710
int hour = localTime.getHour(); //23
int hour1 = localTime.get(ChronoField.HOUR_OF_DAY); //23
int minute = localTime.getMinute(); //11
int minute1 = localTime.get(ChronoField.MINUTE_OF_HOUR); //11
int second = localTime.getSecond(); //11
int second1 = localTime.get(ChronoField.SECOND_OF_MINUTE); //11
LocalDateTime localDateTime = LocalDateTime.now(); //2020-06-01T23:23:50.559
Instant instant = Instant.now(); //2020-06-01T15:27:18.608Z
long currentSecond = instant.getEpochSecond(); //1591025238
long currentMilli = instant.toEpochMilli(); //1591025238608
System.currentTimeMillis(); //1591025406619//2020
文章标题:java8 LocalDateTime
文章链接:http://soscw.com/index.php/essay/38894.html