Skip to content

Instantly share code, notes, and snippets.

@jkw552403
jkw552403 / calendar_toString
Created November 5, 2014 07:53
Android Calendar to String or String to Calendar
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();
}