Java Utililty Methods Date Format

List of utility methods to do Date Format

Description

The list of methods to do Date Format are organized into topic(s).

Method

DatedateFormatCheck(String source, String format)
date Format Check
if (source == null) {
    throw new ParseException("date string to check is null", 0);
if (format == null) {
    throw new ParseException("format string to check date is null", 0);
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.KOREA);
Date date = null;
...
Stringdateformate(String reg, Date newdate)
dateformate
if (!reg.equals(REG)) {
    REG = reg;
    simpleDateFormat = new SimpleDateFormat(REG);
return simpleDateFormat.format(newdate);
DatedateFormater(String dataStr, String dataFormat)
date Formater
DateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.ENGLISH);
Date date = null;
try {
    date = dateFormat.parse(dataStr);
} catch (ParseException e) {
    e.printStackTrace();
return date;
...
StringdateFormatString(Date date)
date Format String
return getDate2Str(DATE_FORMAT_1, date);
StringdateFormatted(Date date)
Returns the date with the format yyyy/MM/dd HH:mm:ss.
String result = "";
if (date != null) {
    result = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date);
return result;
SimpleDateFormatdateFormatter(String dateFormat)
date Formatter
return new SimpleDateFormat(dateFormat);
StringdateFormatTime(final Date date)
Formats a Date to the application wide format for time
SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT);
return sdf.format(date);
StringdateFormatToString(Date date, String format)
date Format To String
if (date == null) {
    return null;
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
    return sdf.format(date);
} catch (Exception e) {
    e.printStackTrace();
...
StringdateFormatToString(String source, String format)
date Format To String
if (source == null || "".equals(source))
    return null;
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setLenient(false);
return dateFormat.format(source);
DateFormatdateFormatUTC()
date Format UTC
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
return df;