List of utility methods to do Date to String Convert
String | getFriendlyLocalDateTime(Date date) Return timestamp in human-readable form wrt local timezone final SimpleDateFormat sdf = new SimpleDateFormat( friendlyDateFormat); sdf.setTimeZone(TimeZone.getDefault()); return sdf.format(date); |
String | dateTimeToString(final Date date) date Time To String if (date == null) return "Never"; return DateFormat.getDateTimeInstance().format(date); |
String | dateToString(Date date) date To String if (date == null) { return null; return format.format(date); |
String | datesToString(final Date start, final int duration) dates To String return new SimpleDateFormat("EEE @HH:mm").format(start) + " - " + duration + " min"; |
String | datesToString(final Date start, final int duration) dates To String return new SimpleDateFormat("EEEEEEEE dd @HH:mm").format(start) + " - " + duration + " min"; |
String | convertDateToString(Date date) convert Date To String SimpleDateFormat df = new SimpleDateFormat("yyyy-MMM-dd"); return df.format(date); |
String | toSimpleDateFormattedString(Date date) to Simple Date Formatted String try { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); return sdf.format(date); } catch (Exception e) { return null; |
String | toStringFromDate(Date date) to String From Date SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a"); String return_date = sd.format(date); return return_date; |
String | toUTCFormattedString(Date date) to UTC Formatted String SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); |
void | updateDate(DatePicker picker, Date date) Convinient method to update a date in a DatePicker . if (picker != null && date != null) { Calendar c = GregorianCalendar.getInstance(); c.setTime(date); int y = c.get(Calendar.YEAR); int m = c.get(Calendar.MONTH); int d = c.get(Calendar.DAY_OF_MONTH); picker.updateDate(y, m, d); |