Java examples for java.time:Day
Get the last timestamp in this day.
//package com.java2s; import java.time.*; public class Main { /**//w w w . ja v a2 s. c om * Get the last timestamp in this day. * * @param timestamp * @return */ public static long getDayTailMills(long timestamp) { Instant instant = Instant.ofEpochMilli(timestamp); ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()); ZonedDateTime dateHead = ZonedDateTime.of(dateTime.getYear(), dateTime.getMonthValue(), dateTime.getDayOfMonth(), 23, 59, 59, 1000000000 - 1, ZoneId.systemDefault()); return dateHead.toInstant().toEpochMilli(); } }