java8的线程安全时间格式化类

// TODO 使用java8的线程安全时间格式化类

 LocalDate localDate = LocalDate.now();

 int month = localDate.getMonthValue();

 String currentDate = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));

 String monthStr = month < 10 ? "0" + month : String.valueOf(month);

// 当前日期所在月份的第一天 

 String currentMontFirstDay = localDate.getYear() + "-" + monthStr + "-0" + 1;

猜你喜欢

转载自blog.csdn.net/l244112311/article/details/106725581
今日推荐