//解析日期
String dateStr= "2018年12月18日";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
LocalDate date= LocalDate.parse(dateStr, formatter);
//日期轉(zhuǎn)換為字符串
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm a");
String nowStr = now .format(format);
System.out.println(nowStr);
kotlin 判斷是否是今天君编;Date 轉(zhuǎn)LocalDateTime
fun Date.isToday(): Boolean {
val now = LocalDateTime.now()
val format = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val ldt = LocalDateTime.ofInstant(this.toInstant(), ZoneId.systemDefault())
return ldt.format(format) == now.format(format)
}