List of utility methods to do Calendar to String Convert
String | convertToDateStamp(Calendar cal) Convert given date to string OutputFormat: yyyymmdd_hhmm String year = String.valueOf(cal.get(Calendar.YEAR)); String month = String.valueOf(cal.get(Calendar.MONTH) + 1); if (month.length() == 1) { month = "0" + month; String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); if (day.length() == 1) { day = "0" + day; ... |
String | toSimpleDate(Calendar calendar) Recieves a calendar instance and returns a String with simple date format ("d MMM, yyyy" = "14 Oct, 2012") return toSimpleDate(calendar, "d MMM, yyyy"); |
String | toHumanDate(Calendar cal) Formats a calendar instance to relative timestamp. Calendar now = GregorianCalendar.getInstance(); int years = cal.get(Calendar.YEAR) - now.get(Calendar.YEAR); int months = cal.get(Calendar.MONTH) - now.get(Calendar.MONTH); int days = cal.get(Calendar.DAY_OF_MONTH) - now.get(Calendar.DAY_OF_MONTH); if (years == 1) return "next year"; else if (years > 1) ... |
String | calendarToString(Calendar date) calendar To String SimpleDateFormat dateformatter = new SimpleDateFormat( "dd/MM/yyyy HH:mm:ss"); return dateformatter.format(date.getTime()); |