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

StringconvertDateToXSDString(Date date)
Converts an instance of Date into the canonical lexical representation of an XSD dateTime with the following exceptions: - Dates before 1 CE (i.e.
if (date == null) {
    return null;
StringBuilder lexicalForm;
String dateTime = convertDateToString(date, true);
int len = dateTime.length() - 1;
if (dateTime.indexOf('.', len - 4) != -1) {
    while (dateTime.charAt(len - 1) == '0') {
...
StringconvertDayToString(Date aDate)
convert Day To String
return getDateTime(HOMI_TIME_FORMAT, aDate);
StringdateFmtToString(Date date, SimpleDateFormat fmt)
date Fmt To String
return fmt.format(date);
StringdateFormat(Date d, String formatStr)
date Format
return new java.text.SimpleDateFormat(formatStr).format(d);
StringdateFormat(Date date)
date Format
if (date == null) {
    return "";
return getFormat(dateFormat).format(date);
StringdateFormat(Date date)
date Format
if (date != null) {
    DateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    return sf.format(date);
} else {
    return "";
StringdateFormat(Date date)
date Format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
StringdateFormat(Date date)
Format a Date object into a string format for a day that meets submission report standard.
DateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
return sdf.format(date);
DatedateFormat(Date date)
date Format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date value = new Date();
try {
    value = sdf.parse(sdf.format(date));
} catch (ParseException e) {
    e.printStackTrace();
return value;
...
StringdateFormat(Date date, String format)
Transforma uma data para uma string no formato especificado.
if (date == null)
    return "";
SimpleDateFormat objDateFormat = new SimpleDateFormat(format);
return objDateFormat.format(date);