Java Utililty Methods Date to String

List of utility methods to do Date to String

Description

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

Method

StringdateToString(Date pDate, String pFormat)
Format a date in string using pFormat.
SimpleDateFormat dateFormat = new SimpleDateFormat(pFormat);
return dateFormat.format(pDate);
StringdateToString(Date pdttValue, String pstrDateFormat)
Date convert to String.
String pstrDate = null; 
if (pdttValue == null || "".equals(pdttValue)) {
    return null;
String formatStyle = null;
if ((pstrDateFormat == null) || (pstrDateFormat.equals(""))) {
    formatStyle = DATE_FORMAT;
} else {
...
StringDateToString(Date thisdate, Locale locale)
Date To String
if (thisdate != null) {
    SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance();
    sdf.applyPattern("dd-MM-yyyy");
    return sdf.format(thisdate);
} else {
    return "";
StringdateToString(final Date date)
Transformiert java.util.Date in ein HL7 String
if (date == null) {
    return null;
Calendar cal = new GregorianCalendar();
cal.setTime(date);
String pattern = DTM_DATE_TIME_PATTERN;
if (cal.get(Calendar.SECOND) == 0) {
    pattern.substring(0, pattern.length() - 2);
...
StringdateToString(final Date value, final boolean utc)
Converts a date to an ISO8601 string.
String result = null;
if (utc) {
    result = ISO_UTC_LOCAL.get().format(value);
} else {
    result = ISO_LOCAL.get().format(value);
return result;
StringdateToString(java.util.Date currdate, String strFormat)
date To String
String returnDate = "";
try {
    SimpleDateFormat sdf = new SimpleDateFormat(strFormat);
    if (currdate == null)
        return returnDate;
    else
        returnDate = sdf.format(currdate);
} catch (NullPointerException e) {
...
DatedateToString(String date, String format)
date To String
if (notEmpty(date)) {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    try {
        return sdf.parse(date);
    } catch (ParseException e) {
        e.printStackTrace();
    return new Date();
...
StringdateToString(String str, DateTimeFormatter dateTimeFormatter)
date To String
DateTime dt = dateTimeFormatter.parseDateTime(str);
return dt.toString(fmt);
StringdateToString1(Date date, String formatIn)
date To String
String format = formatIn;
if (date == null) {
    return "";
if (format == null) {
    format = patternD;
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format);
...
StringdateToString_yyyyMMddHHmmssSSS(Date date)
date To Strinyyyy M Mdd H Hmmss SSS
if (date == null) {
    return null;
return formatDateTime(date, DATETIME_PATTERN_LONG2);