Joda Time时间常用操作
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
LocalDateTime localDateTime=LocalDateTime.now();
localDateTime = localDateTime.plusDays(1)
.plusYears(1)
.plusMonths(1)
.plusWeeks(1)
.minusMillis(1)
.minusHours(1)
.minusSeconds(1);
Date date2 = localDateTime.toDate();
Calendar calendar2 = localDateTime.toCalendar(Locale.CHINA);
Joda Time 时间 获取固定日期
LocalDate localDate = LocalDate.now().withDayOfMonth(20);
LocalDate lastLocalDate = LocalDate.now().dayOfMonth().withMaximumValue();
LocalDate minLocalDate = LocalDate.now().dayOfMonth().withMinimumValue();
计算两日期相差的天数和月份
LocalDate start=new LocalDate(2018, 1,18);
LocalDate end=new LocalDate(2018, 1, 20);
int days = Days.daysBetween(start, end).getDays();
LocalDate startMonth=new LocalDate(2018, 1,1);
LocalDate endMonth=new LocalDate(2020, 1, 1);
int months = Months.monthsBetween(startMonth,endMonth).getMonths();
Joda Time 日期转换
DateTime dateTime=new DateTime(2018, 1, 8, 18, 23,55);
LocalDate.fromDateFields(new Date());
LocalDate.parse("2018-11-11");