Java examples for java.time:Day
Get the first timestamp in this day.
//package com.java2s; import java.time.*; public class Main { /**//from w w w . j a v a 2 s . c o m * Get the first timestamp in this day. * * @param timestamp * @return */ public static long getDayHeadMills(long timestamp) { Instant instant = Instant.ofEpochMilli(timestamp); ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()); ZonedDateTime dateHead = ZonedDateTime.of(dateTime.getYear(), dateTime.getMonthValue(), dateTime.getDayOfMonth(), 0, 0, 0, 0, ZoneId.systemDefault()); return dateHead.toInstant().toEpochMilli(); } }