Created
November 5, 2014 07:53
-
-
Save jkw552403/77468271e9a5d89789a3 to your computer and use it in GitHub Desktop.
Android Calendar to String or String to Calendar
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
SimpleDateFormat calendarFormatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH); | |
Calendar now = Calendar.getInstance(); | |
String strFromCal = calendarFormatter.format(now); | |
Calendar calFromStr = Calendar.getInstance(); | |
try { | |
calFromStr.setTime(calendarFormatter.parse(strFromCal)); | |
} catch (ParseException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment