/* 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 data
= "2013-01-08T20:11:48Z"; DateTimeFormatter originalFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
DateTimeFormatter targetFormat = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
// Com isso já da pra fazer várias manipu
LocalDateTime dateTime = LocalDateTime.parse(data, originalFormat);
// ou assim
DateTimeFormatter formatador = DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM)
.
withLocale(new Locale("pt",
"br"));
// ou assim
ZonedDateTime zoned = dateTime.atZone(ZoneId.of("America/Sao_Paulo"));
DateTimeFormatter formatador2 = DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.LONG)
.
withLocale(new Locale("pt",
"br"));
System.
out.
println(dateTime.
format(targetFormat
)); System.
out.
println(zoned.
format(formatador
)); System.
out.
println(zoned.
format(formatador2
)); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnRpbWUuKjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU3RyaW5nIGRhdGEgPSAiMjAxMy0wMS0wOFQyMDoxMTo0OFoiOwoJCURhdGVUaW1lRm9ybWF0dGVyIG9yaWdp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