fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.*;
  7. import java.time.format.*;
  8.  
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. ZonedDateTime zdt = LocalDateTime.parse("2025-04-26T10:00").atZone(ZoneId.of("Europe/Paris"));
  16.  
  17. String fr = zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneId.of("Europe/Paris")));
  18. System.out.println("FR: " + fr);
  19.  
  20. String ny = zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneId.of("America/New_York")));
  21. System.out.println("NY: " + ny);
  22.  
  23. String fi = zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneId.of("Europe/Helsinki")));
  24. System.out.println("FI: " + fi);
  25.  
  26. String no = zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneId.of("Europe/Oslo")));
  27. System.out.println("NO: " + no);
  28. }
  29. }
Success #stdin #stdout 0.25s 35780KB
stdin
Standard input is empty
stdout
FR: Sat, 26 Apr 2025 10:00:00 +0200
NY: Sat, 26 Apr 2025 04:00:00 -0400
FI: Sat, 26 Apr 2025 11:00:00 +0300
NO: Sat, 26 Apr 2025 10:00:00 +0200