List of usage examples for java.time LocalDateTime with
@Override public LocalDateTime with(TemporalField field, long newValue)
From source file:Main.java
public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); LocalDateTime t = a.with(ChronoField.YEAR, 2012); System.out.println(t);//from ww w.j a v a2 s . c o m }
From source file:edu.usu.sdl.openstorefront.common.util.TimeUtil.java
/** * Get the end of the day passed in/*from ww w . ja va2s . co m*/ * * @param date * @return end of the day or null if date was null */ public static Date endOfDay(Date date) { if (date != null) { Instant instant = Instant.ofEpochMilli(date.getTime()); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); localDateTime = localDateTime.withHour(23).withMinute(59).withSecond(59) .with(ChronoField.MILLI_OF_SECOND, 999); return new Date(localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli()); } return date; }