Java Utililty Methods Time Format

List of utility methods to do Time Format

Description

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

Method

StringgetFormatTimeString(Date date, String pattern)
get Format Time String
SimpleDateFormat sDateFormat = getDateFormat(pattern);
synchronized (sDateFormat) {
    return sDateFormat.format(date);
DateFormatgetFullDateTimeFormat()
Gets the full datetime formatter.
return FULL_DATETIME_FORMAT;
StringgetFullTime(String format, Date date)
get Full Time
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);
StringgetGenerationTime(String format)
generate current time
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US);
String sysdate = formatter.format(new Date());
return sysdate;
intgetIntegerDateTime(Date date, String dateFormat)
get Integer Date Time
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
int dateTime = Integer.parseInt(sdf.format(date.getTime()));
return dateTime;
StringgetShowTime(Date date, String format)
get Show Time
SimpleDateFormat df = new SimpleDateFormat(format);
if (date == null) {
    return "";
} else {
    return df.format(date);
SimpleDateFormatgetStartTimeFormatter()
get Start Time Formatter
return startTimeFormatter.get();
StringgetStrDateByFormat(Date time, String format)
get Str Date By Format
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
if (time == null) {
    return "";
if (format == null || format.equals("")) {
    return dateFormat.format(time);
} else {
    SimpleDateFormat f = new SimpleDateFormat(format);
...
StringgetStrDateTime()
get Str Date Time
return getStrDateTime(new Date());
StringgetStringFormatFromDateTime(long pDateTime, String format)
formats the supplied time in millis to the one specifiedin the format.
format = format != null ? format : "dd-MM-yyyy HH:mm:ss Z";
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
dateFormat.setTimeZone(getServerTimeZone());
return dateFormat.format(new Date(pDateTime));