1.// The current date and timejava
LocalDateTime.now();ide
// construct from valuesui
LocalDate.of(2012, 12, 12);spa
LocalDate.of(2012, Month.DECEMBER, 12);orm
// Somewhere in the middle of 1970ip
LocalDate.ofEpochDay(150);get
// the train I took home todayit
LocalTime.of(17, 18);io
// From a Stringast
2.LocalDateTime timePoint = ...
LocalDate theDate = timePoint.getDate();
int monthAsInt = timePoint.getMonthValue();
Month month = timePoint.getMonth();
int day = timePoint.getDayOfMonth();
day = timePoint.getDayOfYear();
timePoint.getSecond();http://www.huiyi8.com/jiaoben/
timePoint.getNano(); JQuery特效
3.LocalDateTime timePoint = ...
// Set the value, returning a new object
LocalDateTime another = timePoint.withDayOfMonth(10).withYear(2010);
// You can use direct manipulation methods, or pass a value and field pair
LocalDateTime yetAnother = another.plusWeeks(3).plus(3, WEEKS);
4.import static javax.time.calendrical.DateTimeAdjusters.*;
LocalDateTime timePoint = ...
// Statically imported (see above)
foo = timePoint.with(lastDayOfMonth());
bar = timePoint.with(firstDayOfYear());
// Adjusters can also be parameterised
timePoint.with(lastInMonth(TUESDAY));
timePoint.with(previousOrSame(WEDNESDAY));
// Using value classes as adjusters
timePoint.with(LocalTime.now());
5.LocalDate date = ...
date.truncatedTo(DAYS);
LocalTime time = ...
time.truncatedTo(MICROS);
time.truncatedTo(SECONDS)