Chinaunix首页 | 论坛 | 博客
  • 博客访问: 88969
  • 博文数量: 100
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 658
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-10 08:29
文章分类

全部博文(100)

文章存档

2014年(100)

我的朋友

分类: 信息化

2014-07-23 16:12:34

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();
timePoint.getNano(); 
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)
阅读(439) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~