How to convert CharSequence to Date? [closed]

Use LocalDate class to parse and generate text in various formats.

DateTimeFormatter in = DateTimeFormatter.ofPattern( "uuuu/MM/dd" ) ; 
LocalDate ld = LocalDate.parse( "1998/10/05" , in ) ;

DateTimeFormatter out = DateTimeFormatter.ofPattern( "dd/MM/uuuu" ) ; 
String output = ld.format( out ) ;

Tip: Educate the publisher of your data about the ISO 8601 standard for exchanging date-time values textually.

Leave a Comment