fork download
  1. import java.time.Instant;
  2. import java.time.LocalDate;
  3. import java.time.LocalDateTime;
  4. import java.time.LocalTime;
  5. import java.time.ZoneId;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. String strDate = "2021-11-25";
  10. String strTime = "15:20";
  11. LocalDateTime ldt = LocalDateTime.of(LocalDate.parse(strDate), LocalTime.parse(strTime));
  12. Instant instant = ldt.toInstant(ZoneId.systemDefault().getRules().getOffset(ldt));
  13. System.out.println(instant);
  14. }
  15. }
Success #stdin #stdout 0.11s 49600KB
stdin
Standard input is empty
stdout
2021-11-25T15:20:00Z