fork download
  1. import java.time.ZoneId;
  2. import java.time.ZonedDateTime;
  3. import java.time.format.DateTimeFormatter;
  4. import java.util.Locale;
  5.  
  6. public class Main {
  7. public static void main(String args[]) {
  8. // ZoneId.systemDefault() returns the default time zone of the JVM. Replace it
  9. // with the applicable ZoneId e.g., ZoneId.of("America/Los_Angeles")
  10. ZonedDateTime now = ZonedDateTime.now(ZoneId.systemDefault());
  11.  
  12. // Default format
  13. System.out.println(now);
  14.  
  15. // Formatted string
  16. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE, MMMM d", Locale.ENGLISH);
  17. String formattedString = now.format(formatter);
  18. System.out.println(formattedString);
  19. }
  20. }
Success #stdin #stdout 0.19s 57824KB
stdin
Standard input is empty
stdout
2024-11-10T12:03:34.749276Z[GMT]
Sunday, November 10