List of utility methods to do Date Format
String | formatTM(Date d) format TM if (d == null) return null; Calendar c = new GregorianCalendar(); c.setTime(d); return formatTM(c, new StringBuffer(10)).toString(); |
Date | fromString(String dateStr) from String return fromString(dateStr, DATE_FORMAT);
|
Date | fromString(String dateStr, String dateFormat) from String return fromString(dateStr, dateFormat, Locale.ENGLISH);
|
Date | fromString(String dateStr, String dateFormat, Locale locale) from String SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale); return format.parse(dateStr); |
String | getBeforeYear() get Before Year String currentYear = getFormatCurrentTime("yyyy"); int beforeYear = Integer.parseInt(currentYear) - 1; return "" + beforeYear; |
String | getCurrentDate() get Current Date return getFormatDateTime(new Date(), "yyyy-MM-dd"); |
String | getCurrentDateString(String dateFormat) get Current Date String Calendar cal = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); sdf.setTimeZone(TimeZone.getDefault()); return sdf.format(cal.getTime()); |
String | getCurrentDateTime() get Current Date Time return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss"); |
String | getCurrentDay() get Current Day return getFormatCurrentTime("dd"); |
int | getCurrentDayOfWeek() get Current Day Of Week int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1; return day == 0 ? (day + 7) : day; |