import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.Instant;
import java.time.ZoneId;
import java.time.*;
import java.time.temporal.ChronoUnit;
class Main {
public static void main(String[] args) {
System.out.println( getStartDateMillis("2019-03-15") );
System.out.println( getEndDateMillis() );
}
/*
return millis representing the start of day using the received dateString yyyy-MM-dd
2018-06-18 00:00:00.000 GMT
*/
static long getStartDateMillis(String dateString) {
LocalDateTime startOfDay = LocalDateTime.of(LocalDate.parse(dateString), LocalTime.MIDNIGHT);
ZonedDateTime zdt = startOfDay.atZone( ZoneId.systemDefault() ) ;
return zdt.toInstant().toEpochMilli();
}
/*
return millis representing the end of day
2018-06-18 23:59:59.999 GMT
*/
static long getEndDateMillis(){
LocalDate localDate = LocalDate.now().plusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return getStartDateMillis( localDate.format(formatter) );
}
}