fork(3) 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.  
  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.  
  15. String input = "2019-07-02T14:23:57.463-01:00[Etc/GMT+1]" ;
  16. ZonedDateTime zdtInput = ZonedDateTime.parse ( input );
  17. Instant instant = zdtInput.toInstant ();
  18.  
  19. ZoneId zDublin = ZoneId.of( "Europe/Dublin");
  20. ZonedDateTime zdtDublin = zdtInput.withZoneSameInstant ( zDublin );
  21.  
  22. System.out.println ("zdtInput: " + zdtInput );
  23. System.out.println ("instant: " + instant );
  24. System.out.println ("zdtDublin: " + zdtDublin );
  25.  
  26.  
  27. }
  28. }
Success #stdin #stdout 0.18s 2184192KB
stdin
Standard input is empty
stdout
zdtInput: 2019-07-02T14:23:57.463-01:00[Etc/GMT+1]
instant: 2019-07-02T15:23:57.463Z
zdtDublin: 2019-07-02T16:23:57.463+01:00[Europe/Dublin]