List of utility methods to do Date Format String Create
DateFormat | getFormat(String pattern) get Format DateFormat format = DFS.get(pattern); if (format == null) { format = new SimpleDateFormat(pattern); DFS.put(pattern, format); return format; |
DateFormatSymbols | getDateFormatSymbols(Locale locale) Gets the DateFormatSymbols based on the given locale. try { Method method = DateFormatSymbols.class.getMethod( "getInstance", new Class[] { Locale.class }); return (DateFormatSymbols) method.invoke(null, new Object[] { locale }); } catch (Exception ex) { return new DateFormatSymbols(locale); |
String | changeFormat(String gmtString, String orgFormat, String format) change Format final Date date = getDateTimeFromString(gmtString, orgFormat); SimpleDateFormat formatter = new SimpleDateFormat(format); return formatter.format(date); |
String | convertFormat(String src, String f1, String f2) convert Format Date date = stringToDate(src, f1);
return dateToString(date, f2);
|
String | dateFormatToString(int date, Context context) date Format To String String dateString = ""; long currentTime = System.currentTimeMillis() / 1000; int dateTime = (int) (currentTime - date) / 60; if (date == 0) { return dateString; if (dateTime > 4320) { dateString = getDateString(date); ... |
DateFormat | getGMTDateFormat() get GMT Date Format DateFormat dateFormat = new SimpleDateFormat( "EEE MMM d HH:mm:ss z yyyy", Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat; |
SimpleDateFormat | getSimpleDateFormat() get Simple Date Format return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
SimpleDateFormat | getSimpleDateFormatter() get Simple Date Formatter if (sDateFormat == null) { sDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); return sDateFormat; |
Date | getDateByFormat(String strDate, String format) get Date By Format SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format); Date date = null; try { date = mSimpleDateFormat.parse(strDate); } catch (ParseException e) { e.printStackTrace(); return date; ... |
String | getStringByFormat(String strDate, String format) get String By Format String mDateTime = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( dateFormatYMDHMS); c.setTime(mSimpleDateFormat.parse(strDate)); SimpleDateFormat mSimpleDateFormat2 = new SimpleDateFormat( format); ... |