fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.* ;
  7. import java.time.format.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. DateTimeFormatter f =
  15. new DateTimeFormatterBuilder()
  16. .parseCaseInsensitive()
  17. .appendPattern( "dd-MMM-uu" )
  18. .toFormatter( Locale.US );
  19. String input = "12-FEB-23";
  20. LocalDate localDate = LocalDate.parse( input , f );
  21. ZoneId z = ZoneId.of( "Asia/Kolkata" );
  22. ZonedDateTime zdt = localDate.atStartOfDay( z );
  23. String output = zdt.format( DateTimeFormatter.RFC_1123_DATE_TIME ) ;
  24.  
  25. System.out.println( zdt ) ;
  26. System.out.println( output ) ;
  27. System.out.println( Runtime.version() ) ;
  28. }
  29. }
Success #stdin #stdout 0.22s 50508KB
stdin
Standard input is empty
stdout
2023-02-12T00:00+05:30[Asia/Kolkata]
Sun, 12 Feb 2023 00:00:00 +0530
12.0.1+12