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

StringformatDate(Date date)
format Date
SimpleDateFormat sdf = new SimpleDateFormat(datePatter);
sdf.setTimeZone(TimeZone.getTimeZone(timeZoneCode));
sdf.setLenient(false);
return sdf.format(date);
StringformatDate(Date date)
Format the Date object to string with format "yyyy-MM-dd"
if (date != null) {
    synchronized (SDF) {
        return SDF.format(date);
} else {
    return null;
StringformatDate(Date date)
format Date
String dateString = date.toString();
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
try {
    dateString = formatter.format(date);
} catch (IllegalArgumentException iae) {
    iae.printStackTrace();
return dateString;
...
StringformatDate(Date date)
format Date
return formatDate(date, localDateFormat);
StringformatDate(Date date)
format Date
SimpleDateFormat sd = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'zzz", Locale.US);
sd.setTimeZone(TimeZone.getTimeZone("GMT"));
return sd.format(new Date());
StringformatDate(Date date)
Convenience method for converting Date to a string representation with minimal overhead.
return date == null ? "" : DATE_FORMAT.get().format(date);
StringformatDate(Date date)
format Date
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
if (date != null) {
    return sdf.format(date);
return "";
StringformatDate(Date date)
format Date
return formatDate(date, DATE_FORMAT);
StringformatDate(Date date)
Format a Date to contain both date and time information with full millisecond precision.
return createDateFormat().format(date);
booleanformatDate(Date date)
format Date
boolean isValid = false;
String formatDate = null;
try {
    if (date != null) {
        SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
        formatDate = df.format(date);
        isValid = isValidDate(formatDate);
} catch (Exception e) {
    isValid = false;
return isValid;