List of utility methods to do Locale Format
String | formatDate(String dateStr, String format, String toFormat) format Date return format(parseDate(dateStr, format), toFormat);
|
String | formatDate(String pattern, Date date, String valueForNull) format Date return date == null ? valueForNull : new SimpleDateFormat(pattern, Locale.getDefault()).format(date); |
String | formatDate(String strDate, Locale locale) format Date String ret = ""; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date date = null; try { date = sdf.parse(strDate); } catch (Exception e) { return ret; DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, locale); ret = df.format(date); return ret; |
Date | formatDate(String value, Locale locale) Checks if the field is a valid date. Date date = null; if (value != null) { try { DateFormat formatter = null; if (locale != null) { formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale); } else { formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); ... |
Date | formatDate2Date(Date date, String format) format Date Date return formatString2Date(formatDate2String(date, format), format);
|
String | formatDate2String(Date date, String format) format Date String if (isNull(date)) return null; SimpleDateFormat sdf = new SimpleDateFormat(format); String dateString = ""; try { dateString = sdf.format(date); } catch (Exception e) { return dateString; |
String | formatDateByFormat(Date date, String format) format Date By Format String result = ""; if (date != null) { try { SimpleDateFormat sdf = new SimpleDateFormat(format); result = sdf.format(date); } catch (Exception ex) { ex.printStackTrace(); return result; |
String | formatDateTime(final Date date) Formats a date string using the currently selected locale. Preconditions.checkNotNull(date, "Error: Date argument can't be null."); return DateFormat.getDateTimeInstance().format(date); |
String | formatDateTime(java.util.Date date, String format, String locale, String timeZone) Formats a date using a format string. SimpleDateFormat dateFormat = getDateFormat(format, locale, timeZone); synchronized (dateFormat) { return dateFormat.format(date); |
String | formatDateToSQLString(Date srcDate) format Date To SQL String SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); return sdf.format(srcDate); |