fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.*;
  8. import java.time.temporal.*;
  9. import java.time.format.*;
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16.  
  17. String input = "Sun Jul 10 17:47:55 EDT 2011" ;
  18. DateTimeFormatter f = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss z uuuu" , Locale.US ) ;
  19. ZonedDateTime zdt = ZonedDateTime.parse( input , f ) ;
  20.  
  21. int dayOfYear = zdt.getDayOfYear() ;
  22.  
  23. System.out.println( "zdt.toString(): " + zdt ) ;
  24. System.out.println( "dayOfYear: " + dayOfYear ) ;
  25.  
  26. }
  27. }
Success #stdin #stdout 0.23s 4386816KB
stdin
Standard input is empty
stdout
zdt.toString(): 2011-07-10T17:47:55-04:00[America/New_York]
dayOfYear: 191