/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.*;
import java.time.format.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String input
= "30 11 2012 12:08:56.235 +0700"; DateTimeFormatter f
= DateTimeFormatter.
ofPattern ( "dd MM uuuu HH:mm:ss.SSS X" ,
Locale.
US ); OffsetDateTime odt = OffsetDateTime.parse ( input , f );
System.
out.
println( "input: " + input
); System.
out.
println( "odt: " + odt
);
Instant instant = odt.toInstant();
System.
out.
println( "instant: " + instant
);
ZonedDateTime zdtKolkata = odt.toInstant ().atZone ( ZoneId.of ( "Asia/Kolkata" ) );
System.
out.
println( "zdtKolkata: " + zdtKolkata
);
// CAUTION: Not recommended. Avoid the legacy date-time classes such as `java.util.Date`.
// CAUTION: Data-loss as `Instant` has resolution in nanoseconds but only milliseconds in `java.util.Date`.
java.
util.
Date utilDate
= java.
util.
Date.
from( instant
); System.
out.
println( "utilDate: " + utilDate
); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnRpbWUuKjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU3RyaW5nIGlucHV0ID0gIjMwIDExIDIwMTIgMTI6MDg6NTYuMjM1ICswNzAwIjsKCQlEYXRlVGltZUZvcm1hdHRlciBmID0gRGF0ZVRpbWVGb3JtYXR0ZXIub2ZQ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