Java Utililty Methods Date Format As

List of utility methods to do Date Format As

Description

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

Method

StringformatDateDay(final Date date)
format Date Day
return new SimpleDateFormat("yyyy-MM-dd").format(date);
StringformatDateForCompleteInfo(Date date)
Formats a date holding all provided info.
return fullDate.format(date);
StringformatDateForGMT(Date moonDate)
Useful date-to-string formatting which I found myself using a lot
DateFormat sdf = SimpleDateFormat.getDateInstance(SHORT);
((SimpleDateFormat) sdf).applyPattern("yyyy-MM-dd");
((SimpleDateFormat) sdf).setTimeZone(TimeZone.getTimeZone("GMT"));
return sdf.format(moonDate);
StringformatDateForLogFileName(Date date)
format Date For Log File Name
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return dateFormat.format(calendar.getTime());
StringformatDateForTAP(Date date)
Utility class that help us to build date strings that can be used in TAP data provider
return new SimpleDateFormat("dd.MM.yyyy").format(date);
StringformatDateForXpath(Date date)
format Date For Xpath
return "xs:dateTime('" + getXpathFormattedDate(date) + 'T' + getXpathFormattedTime(date) + getTimeZone(date)
        + "')";
StringformatDateGMT(Date date)
format Date GMT
return DateFormat.getDateInstance(DateFormat.SHORT).format(date);
StringformatDateHeader(final Date date)
format Date Header
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
return new SimpleDateFormat(DATE_HEADER_FMT).format(date) + GMT_SUFFIX;
StringformatDateHeader(final Date date)
format Date Header
return new SimpleDateFormat(DATE_HEADER_FMT).format(date);
StringformatDateHMS(java.util.Date date)
format Date HMS
String result = "";
if (date != null) {
    try {
        SimpleDateFormat dateFormater = new SimpleDateFormat("HH:mm:ss");
        result = dateFormater.format(date);
    } catch (Exception ex) {
        ex.printStackTrace();
return result;