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

StringfmtTime(Date time)
fmt Time
return fmtTime(time, "yyyy-MM-dd HH:mm:ss");
StringformatDateAccordingToSessionDuration(Calendar cal, int sessionDuration, int offset)
format Date According To Session Duration
long time = cal.getTimeInMillis();
long minutes = (time / (1000 * 60));
int diff = (int) (minutes % sessionDuration);
diff = diff - offset;
if (diff < 0)
    diff += sessionDuration;
time = (minutes - diff) * 1000 * 60;
return df.format(new Date(time));
...
StringformatDateAppello(Date data)
format Date Appello
SimpleDateFormat dateFormat = new SimpleDateFormat(DD_MM_YYYY);
return dateFormat.format(data);
StringformatDateAsFileSystemName()
Returns a date formatted in the standard syncvoice format
final Date date = createDate();
return formatDate(date, "yyyy-MM-dd_HH-mm-ss");
StringformatDateAsYYYYMMDD(Date date)
Format a date as yyyy-MM-dd.
if (date == null) {
    return "";
} else {
    return yyyyMMddFormatter.format(date);
StringformatDateBdChar(Date birthdate)
format Date Bd Char
return birthdate != null ? datetimeFormatBdChar.format(birthdate) : null;
StringformatDateByDefault(Date date)
format Date By Default
if (null == date) {
    return null;
DateFormat df = new SimpleDateFormat(PATTERN_DEFAULT);
String dateStr = df.format(date);
return dateStr;
StringformatDateByYYYYMMDDHHmmss(Date date)
This method is used for formatting date to yyyyMMddHHmmss
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("yyyyMMddHHmmss");
return sdf.format(date);
StringformatDateCkan(Date date)
format Date Ckan
String formattedDate = null;
if (date != null) {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    formattedDate = df.format(date);
return formattedDate;
StringformatDateDashes(Date oDate)
Format a date with dashes.
String sDate = "";
if (oDate != null) {
    SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
    sDate = format.format(oDate);
return sDate;