fork download
  1. import java.time.LocalDate;
  2. import java.time.LocalTime;
  3. import java.time.ZoneId;
  4. import java.time.ZoneOffset;
  5.  
  6. class Main {
  7. public static void main(String[] args) {
  8. ZoneId zoneIndia = ZoneId.of("Asia/Kolkata");
  9. LocalDate date = LocalDate.parse("2023-04-03");
  10.  
  11. System.out.println(date.atStartOfDay(zoneIndia)
  12. .withZoneSameInstant(ZoneOffset.UTC));
  13.  
  14. System.out.println(date.atStartOfDay(zoneIndia).with(LocalTime.MAX)
  15. .withZoneSameInstant(ZoneOffset.UTC));
  16.  
  17. // Or get the exlusive upper range (half-open interval for the day)
  18. System.out.println(date.plusDays(1).atStartOfDay(zoneIndia)
  19. .withZoneSameInstant(ZoneOffset.UTC));
  20. }
  21. }
Success #stdin #stdout 0.14s 52368KB
stdin
Standard input is empty
stdout
2023-04-02T18:30Z
2023-04-03T18:29:59.999999999Z
2023-04-03T18:30Z