自定义时间格式:
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); DateTime dateTime = DateTime.parse("2019-08-02 11:33:56", formatter); System.out.println(dateTime);
输出:
2019-08-02T11:33:56.000+08:00
计算两个日期相差的天数:
DateTime now = DateTime.now(); int days = Days.daysBetween(now.plusDays(30), now).getDays(); System.out.println(days);
输出:
-29
除非注明,否则均为李锋镝的博客原创文章,转载必须以链接形式标明本文链接