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

SimpleDateFormattimeFormatter()
time Formatter
return dateFormatter(TIME_FORMAT_HU);
Stringtimestr(String format, long secs)
timestr
SimpleDateFormat sdf;
Date date;
sdf = new SimpleDateFormat(format);
date = new Date(secs * 1000);
return sdf.format(date);
StringtimeToString(String format, Date date)
time To String
DateFormat df = new SimpleDateFormat(format);
return df.format(date);
StringtoSQLDateTimeFormat(Calendar cal)
create a SQL-friendly datetime string from a Java Calendar
if (cal == null)
    return null;
return toSQLDateTimeFormat(cal.getTime());
StringtoString(Date time, String format)
to String
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.format(time);
StringtoString(String format, long time)
to String
return toString(TimeZone.getDefault(), format, time);
StringtoString(String format, long time)
to String
return new SimpleDateFormat(format).format(time);
StringtoStringFormatTime(long time, String format)
to String Format Time
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new java.util.Date(time));
DatetryToParse(String datetime, SimpleDateFormat format)
try To Parse
try {
    return format.parse(datetime);
} catch (ParseException e) {
    return null;
booleanvalidateDatetimeString(String datetimeString, String format)
validate Datetime String
if (datetimeString == null || datetimeString.equals("")) {
    return false;
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
    sdf.parse(datetimeString);
    return true;
} catch (ParseException e) {
...