List of utility methods to do Date to String Convert
String | getDateByFormatedString(String date) get Date By Formated String Date mDate = null; String dateFormated = ""; Calendar cal = Calendar.getInstance(); if (date != null && !date.isEmpty()) { try { mDate = DateTimeUtil.stringToDate(date); } catch (ParseException e) { Log.e(TAG, "Unparsable date"); ... |
String | getDateTimeString(Date date) get Date Time String SimpleDateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT); String result = df.format(date); return result; |
String | getDateTimeString(Date date, int format, Locale currentLocale) get Date Time String String key = format + "_" + currentLocale.toString(); DateFormat formatter = dateFormats.get(key); if (formatter == null) { formatter = DateFormat.getDateTimeInstance(format, format, currentLocale); dateFormats.put(key, formatter); return formatter.format(date); ... |
String | getFileName() get File Name in format of "yyyy-MM-dd" SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String date = format.format(new Date(System.currentTimeMillis())); return date; |
String | getFormatString(Date date, String dateFormat) get Format String if (date == null || StringUtil.isEmpty(dateFormat)) { return null; return new SimpleDateFormat(dateFormat, Locale.ENGLISH) .format(date); |
float | getHourInFloat(Date date) Converts "2013-09-08 15:30" to 15.5 final long hours = DateUtils.getFragmentInHours(date, Calendar.DAY_OF_MONTH); final long minutes = DateUtils.getFragmentInMinutes(date, Calendar.HOUR_OF_DAY); return hours + (minutes / 60.f); |
String | getLongDateStr(Date date) Converts given date time to long date string. return LONG_DATE_FORMAT.format(date);
|
String | getLongFormat(Date date) get Long Format if (date == null) { return null; return getFormatString(date, LOCAL_LONG_DATE_FORMAT); |
String | getShortDateTimeString(Date date) get Short Date Time String SimpleDateFormat df = new SimpleDateFormat(SHORT_DATE_TIME_FORMAT); return df.format(date); |
String | getShortFormat(Date date) get Short Format if (date == null) { return null; return getFormatString(date, LOCAL_SHORT_DATE_FORMAT); |