fork download
  1. import java.time.LocalDateTime;
  2. import java.time.format.DateTimeFormatter;
  3. import java.time.format.ResolverStyle;
  4.  
  5. class Datas {
  6. public static void main(String[] args) {
  7. DateTimeFormatter original = DateTimeFormatter
  8. .ofPattern("uuuuMMddHHmmss")
  9. .withResolverStyle(ResolverStyle.STRICT);
  10. DateTimeFormatter novo = DateTimeFormatter
  11. .ofPattern("uuuu-MM-dd HH:mm:ss")
  12. .withResolverStyle(ResolverStyle.STRICT);
  13.  
  14. LocalDateTime dataHora = LocalDateTime.parse("20161109103000", original);
  15. String formatado = dataHora.format(novo);
  16. System.out.println(formatado);
  17. }
  18. }
Success #stdin #stdout 0.12s 54800KB
stdin
Standard input is empty
stdout
2016-11-09 10:30:00