1.// The current date and time
LocalDateTime.now();
// construct from values
LocalDate.of(2012, 12, 12);
LocalDate.of(2012, Month.DECEMBER, 12);
// Somewhere in the middle of 1970
LocalDate.ofEpochDay(150);
// the train I took home today
LocalTime.of(17, 18);
// From a String
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(); javascript特效
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)
相关文章
- 09-30SimpleDateFormat(jdk 8之前的日期时间的API测试)
- 09-30Java8 新特性 Lamdba表达式的一些简单用法
- 09-30JDK8的日期时间类3
- 09-30uniapp将时间日期格式化的组件uni-dateformat的用法
- 09-30element 中<el-date-picker></el-date-picker>限制时间为只能选7天内的日期用法全解
- 09-30java 中怎么根据当前时间得到上周一和上周五的日期
- 09-30GBase 8c的日期和时间类型
- 09-30Java8的新特性--方法引用与构造器引用
- 09-30Java 8 日期类的使用
- 09-30Java8新特性interface中的static方法和default方法