Java获取12个月前的月初日期
程序员文章站
2022-05-15 09:49:03
...
public class FirstDayOfLastTwelveMonth {
public static void main(String[] args){
DateTimeFormatter formatter = DateTimeFormatter.forPattern("yyyyMMdd");
DateTime dateTime = formatter.parseDateTime("20151231");
Period period = new Period(0,11,0,0,0,0,0,0);
DateTime theDate = dateTime.minus(period);
DateTime firstDay = theDate.withField(DateTimeFormatter.dayOfMonth, 1)
System.out.println(formatter.print(firstDay));
}
}
上一篇: php文件缓存类汇总
下一篇: 删除指定日期前的文件File