fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.time.*;
  4. import java.lang.*;
  5. import java.time.format.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. DateTimeFormatter parser = DateTimeFormatter
  13. .ofPattern("dd/MM/uuuu HH:mm:ss");
  14. String str = "31/04/2008 11:35:04";
  15. // 31 de abril é ajustado para 30 de abril
  16. System.out.println(LocalDateTime.parse(str, parser).atOffset(ZoneOffset.ofHours(-3)));
  17. }
  18. }
Success #stdin #stdout 0.15s 2184192KB
stdin
Standard input is empty
stdout
2008-04-30T11:35:04-03:00