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.format.* ;
  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. Locale locale = new Locale( "en" , "IN" ) ;
  16. DateTimeFormatter f = DateTimeFormatter.ofPattern( "E MMM dd HH:mm:ss zzz uuuu" ) ;
  17. ZonedDateTime zdt = ZonedDateTime.parse( "Tue Apr 30 00:00:00 UTC 1996" , f ) ;
  18.  
  19. OffsetDateTime odt = zdt.toOffsetDateTime() ;
  20.  
  21. ZoneId z = ZoneId.of( "Asia/Kolkata" ) ;
  22. ZonedDateTime zdtKolkata = zdt.withZoneSameInstant( z ) ;
  23.  
  24. System.out.println( zdt ) ;
  25. System.out.println( odt ) ;
  26. System.out.println( zdtKolkata ) ;
  27.  
  28. }
  29. }
Success #stdin #stdout 0.21s 55448KB
stdin
Standard input is empty
stdout
1996-04-30T00:00Z[UTC]
1996-04-30T00:00Z
1996-04-30T05:30+05:30[Asia/Kolkata]