fork 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. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. Period p = Period.ofDays( 2 ) ;
  15. ZoneId z = ZoneId.of( "America/Los_Angeles" ) ;
  16. ZonedDateTime zdt = ZonedDateTime.now( z ).plus( p ) ;
  17. Locale locale = Locale.US ;
  18. DateTimeFormatter f =
  19. DateTimeFormatter
  20. .ofPattern( "EEE MMM dd HH:mm:ss z uuuu" )
  21. .withLocale( locale ) ;
  22. String output = zdt.format( f ) ;
  23. System.out.println( output ) ;
  24.  
  25. System.out.println(
  26. ZonedDateTime.now( ZoneId.of( "America/Los_Angeles" ) ).plus( Period.ofDays( 2 ) ).format( DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss z uuuu" ).withLocale( Locale.US ) )
  27. );
  28. }
  29.  
  30. }
Success #stdin #stdout 0.26s 54656KB
stdin
Standard input is empty
stdout
Sun Jan 29 14:02:31 PST 2023
Sun Jan 29 14:02:32 PST 2023