Here you can find the source of withTime(LocalDate day, int hours, int minutes)
public static Instant withTime(LocalDate day, int hours, int minutes)
//package com.java2s; //License from project: Open Source License import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.util.Date; public class Main { public static Instant withTime(LocalDate day, int hours, int minutes) { if (day == null) { day = LocalDate.now(); }/* w w w.ja va2 s .c o m*/ LocalDateTime dateTime = LocalDateTime.of(day, LocalTime.of(hours, minutes)); return toInstant(dateTime); } public static Instant toInstant(Date date) { if (date == null) { return null; } Instant moment = Instant.ofEpochMilli(date.getTime()); return moment; } public static Instant toInstant(LocalDateTime localDateTime) { if (localDateTime == null) { return null; } Instant moment = localDateTime.atZone(ZoneId.systemDefault()).toInstant(); return moment; } }