/* 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
= "2017-01-23 12:34 PM"; DateTimeFormatter f = DateTimeFormatter.ofPattern ( "uuuu-MM-dd hh:mm a" );
LocalDateTime ldt = LocalDateTime.parse ( input , f );
ZoneId z = ZoneId.of ( "America/Montreal" );
ZonedDateTime zdt = ldt.atZone ( z );
Instant instant = zdt.toInstant ();
String output
= instant.
toString () .replace ( "T" , " " ) // Substitute SPACE for T.
.replace ( "Z" , " Z" ); // Insert SPACE before Z.
System.
out.
println ( "ldt.toString(): " + ldt
); System.
out.
println ( "zdt.toString(): " + zdt
); System.
out.
println ( "instant.toString(): " + instant
); System.
out.
println ( "output: " + output
);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CmltcG9ydCBqYXZhLnRpbWUuZm9ybWF0Lio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoKICAgICAgICBTdHJpbmcgaW5wdXQgPSAiMjAxNy0wMS0yMyAxMjozNCBQTSI7CiAgICAgICAgRGF0ZVRpbWVGb3JtYXR0ZXIgZiA9IERhdGVUaW1lRm9ybWF0dGVyLm9mUGF0dGVybiAoICJ1dXV1LU1NLWRkIGhoOm1tIGEiICk7CiAgICAgICAgTG9jYWxEYXRlVGltZSBsZHQgPSBMb2NhbERhdGVUaW1lLnBhcnNlICggaW5wdXQgLCBmICk7CgogICAgICAgIFpvbmVJZCB6ID0gWm9uZUlkLm9mICggIkFtZXJpY2EvTW9udHJlYWwiICk7CiAgICAgICAgWm9uZWREYXRlVGltZSB6ZHQgPSBsZHQuYXRab25lICggeiApOwoKICAgICAgICBJbnN0YW50IGluc3RhbnQgPSB6ZHQudG9JbnN0YW50ICgpOwoKICAgICAgICBTdHJpbmcgb3V0cHV0ID0gaW5zdGFudC50b1N0cmluZyAoKQogICAgICAgICAgICAgICAgLnJlcGxhY2UgKCAiVCIgLCAiICIgKSAvLyBTdWJzdGl0dXRlIFNQQUNFIGZvciBULgogICAgICAgICAgICAgICAgLnJlcGxhY2UgKCAiWiIgLCAiIFoiICk7IC8vIEluc2VydCBTUEFDRSBiZWZvcmUgWi4KCiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuICggImxkdC50b1N0cmluZygpOiAiICsgbGR0ICk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuICggInpkdC50b1N0cmluZygpOiAiICsgemR0ICk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuICggImluc3RhbnQudG9TdHJpbmcoKTogIiArIGluc3RhbnQgKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4gKCAib3V0cHV0OiAiICsgb3V0cHV0ICk7CgoJfQp9