http://insightfullogic.com/blog/2012/dec/14/date-and-time-java-8-1/
标签: <无>
[代码] [Java]代码
05 |
LocalDate.of( 2012 , 12 , 12 ); |
06 |
LocalDate.of( 2012 , Month.DECEMBER, 12 ); |
09 |
LocalDate.ofEpochDay( 150 ); |
15 |
LocalTime.parse( "10:15:30" ); |
[代码] [Java]代码
01 |
LocalDateTime timePoint = ... |
03 |
LocalDate theDate = timePoint.getDate(); |
05 |
int monthAsInt = timePoint.getMonthValue(); |
06 |
Month month = timePoint.getMonth(); |
08 |
int day = timePoint.getDayOfMonth(); |
09 |
day = timePoint.getDayOfYear(); |
11 |
timePoint.getSecond(); |
[代码] [Java]代码
1 |
LocalDateTime timePoint = ... |
4 |
LocalDateTime another = timePoint.withDayOfMonth( 10 ).withYear( 2010 ); |
7 |
LocalDateTime yetAnother = another.plusWeeks( 3 ).plus( 3 , WEEKS); |
[代码] [Java]代码
01 |
import static javax.time.calendrical.DateTimeAdjusters.*; |
03 |
LocalDateTime timePoint = ... |
06 |
foo = timePoint.with(lastDayOfMonth()); |
07 |
bar = timePoint.with(firstDayOfYear()); |
10 |
timePoint.with(lastInMonth(TUESDAY)); |
11 |
timePoint.with(previousOrSame(WEDNESDAY)); |
14 |
timePoint.with(LocalTime.now()); |
[代码] [Java]代码
2 |
date.truncatedTo(DAYS); |
5 |
time.truncatedTo(MICROS); |
6 |
time.truncatedTo(SECONDS); |