1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public static void main(String[] args) { LocalDateTime record = LocalDateTime.now().minusDays(5); LocalDateTime endOfDay = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); LocalDateTime beginOfDay = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); LocalDateTime yesterday = LocalDateTimeUtil.beginOfDay(beginOfDay.minusDays(1)); if (beginOfDay.isBefore(record) && endOfDay.isAfter(record)){ String s = LocalDateTimeUtil.formatNormal(record); String[] split = s.split(" "); if (split.length == 2) { System.out.println("今天" + " " + split[1]); } }else if (yesterday.isBefore(record) && beginOfDay.isAfter(record)){ String s = LocalDateTimeUtil.formatNormal(record); String[] split = s.split(" "); if (split.length == 2) { System.out.println("昨天" + " " + split[1]); } }else { System.out.println(LocalDateTimeUtil.formatNormal(record)); } }
|