java8使用时间计算
public static void main(String[] args) { LocalDate localDate = LocalDate.now(); //1.获取周日 LocalDate with = localDate.with(DayOfWeek.SUNDAY); System.out.println(with); //2.获取本月最后一天 with = localDate.with(TemporalAdjusters.lastDayOfMonth()); System.out.println(with); //3.获取本月上一个周三 TemporalAdjuster temporalAdjuster = TemporalAdjusters.nextOrSame(DayOfWeek.WEDNESDAY); with = with.with(TemporalAdjusters.previousOrSame(DayOfWeek.WEDNESDAY)); System.out.println(with); //4.下一个周日 with = localDate.with(TemporalAdjusters.next(DayOfWeek.WEDNESDAY)); //(不含今天) System.out.println(with); System.out.println(DayOfWeek.valueOf("WEDNESDAY")); String windowsName = getWindowsName(localDate); System.out.println(windowsName); System.out.println(localDate.with(TemporalAdjusters.lastInMonth(DayOfWeek.WEDNESDAY))); System.out.println(7 % 14); System.out.println(0 % 14); }
标签:DayOfWeek,TemporalAdjusters,System,日期,计算,println,localDate,java8,out From: https://www.cnblogs.com/zhangshiwen/p/18001156