ZoneDateTime 轉換Date

final ZonedDateTime now = ZonedDateTime.now(); //當前時間
final ZonedDateTime todayZero = now.truncatedTo(ChronoUnit.DAYS); //今天的0點
final ZonedDateTime tomorrowZero = todayZero.plusDays(1); //明天的0點

final ZonedDateTime firstDayOfMonth = todayZero.withDayOfMonth(1); //當月1號0點
final ZonedDateTime nextDayOfMonth = firstDayOfMonth.plusMonths(1);//下月1號0點


final Date from = Date.from(todayZero.toInstant()); //ZoneDateTime 轉換成Date
相關文章
相關標籤/搜索