Java Utililty Methods Hour Format

List of utility methods to do Hour Format

Description

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

Method

StringformatDuration(long duration)
format Duration
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss:SSS");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
return format.format(new Date(duration));
StringformatDuration(long value)
format Duration
if (twoDigitFormat == null || oneDigitFormat == null) {
    oneDigitFormat = new DecimalFormat("0");
    twoDigitFormat = new DecimalFormat("00");
long[] divisors = { 1000, 60, 60, 24 };
double[] result = new double[divisors.length];
for (int i = 0; i < divisors.length; i++) {
    result[i] = value % divisors[i];
...
StringformateDataC(Date date)
formate Data C
if (date == null) {
    return null;
try {
    SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_D, Locale.US);
    return format.format(date);
} catch (Exception e) {
return null;
StringformateDate(Date date)
formate Date
return formateDate(date, BASE_PATTERN);
StringformateDate(Date date, String format)
formate Date
if (date == null) {
    return "";
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);
DateforMateDate(String dateStr)
for Mate Date
Date date = null;
try {
    String pattern = "EEE, dd MMM yyyy HH:mm:ss z";
    SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
    date = format.parse(dateStr);
    return date;
} catch (Exception e) {
    e.printStackTrace();
...
StringformateDaTime(Date date)
formate Da Time
return dateToString(date, patternD);
StringformateEndTimeString(String time)
formate End Time String
return formateTimeString(time, "end");
DateformatEndTime(String datePre)
format End Time
if (datePre == null)
    return null;
String dateStr = addDateEndfix(datePre);
return getFormatDateTime(dateStr);
DateformatFF(String date)
format FF
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_STYLE_F);
try {
    if (null != date && !"".equals(date)) {
        return sdf.parse(date);
} catch (ParseException e) {
    e.printStackTrace();
return null;