Last active
March 9, 2023 11:02
-
-
Save adojos/d7c0e97f1a25c2a02fffe368f125f9a8 to your computer and use it in GitHub Desktop.
Java: Convert String to Date Using Calendar #java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void convertToCalendar() throws ParseException { | |
String strDate = "2015-06-12"; | |
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); | |
Date date = dateFormatter.parse(strDate); | |
Calendar cal = Calendar.getInstance(); | |
cal.setTime(date); | |
System.out.println(date); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment