import java.time.OffsetDateTime;
import java.time.format.DateTimeParseException;
public class Main {
public static void main
(String[] args
) { System.
out.
println("Java Version: " + System.
getProperty("java.version"));
"2023-10-05T15:14:29.123456789Z", // 9 digits
"2023-10-05T15:14:29.12345678Z", // 8 digits
"2023-10-05T15:14:29.1234567Z", // 7 digits
"2023-10-05T15:14:29.123456Z", // 6 digits
"2023-10-05T15:14:29.12345Z", // 5 digits
"2023-10-05T15:14:29.1234Z", // 4 digits
"2023-10-05T15:14:29.123Z", // 3 digits
"2023-10-05T15:14:29.12Z", // 2 digits
"2023-10-05T15:14:29.1Z", // 1 digit
"2023-10-05T15:14:29Z" // no fractional seconds
};
for (String timestamp
: timestamps
) { try {
System.
out.
println("Parsed date: " + OffsetDateTime.
parse(timestamp
)); } catch (DateTimeParseException e) {
System.
err.
println("Failed to parse: " + timestamp
+ " - " + e.
getMessage()); }
}
}
}
aW1wb3J0IGphdmEudGltZS5PZmZzZXREYXRlVGltZTsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuRGF0ZVRpbWVQYXJzZUV4Y2VwdGlvbjsKCnB1YmxpYyBjbGFzcyBNYWluIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkphdmEgVmVyc2lvbjogIiArIFN5c3RlbS5nZXRQcm9wZXJ0eSgiamF2YS52ZXJzaW9uIikpOwoKICAgICAgICBTdHJpbmdbXSB0aW1lc3RhbXBzID0gewogICAgICAgICAgICAgICAgIjIwMjMtMTAtMDVUMTU6MTQ6MjkuMTIzNDU2Nzg5WiIsIC8vIDkgZGlnaXRzCiAgICAgICAgICAgICAgICAiMjAyMy0xMC0wNVQxNToxNDoyOS4xMjM0NTY3OFoiLCAgLy8gOCBkaWdpdHMKICAgICAgICAgICAgICAgICIyMDIzLTEwLTA1VDE1OjE0OjI5LjEyMzQ1NjdaIiwgICAvLyA3IGRpZ2l0cwogICAgIC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