Java Hour Calculate toStringHour(int hours, int minutes, int seconds, int millis)

Here you can find the source of toStringHour(int hours, int minutes, int seconds, int millis)

Description

to String Hour

License

Open Source License

Declaration

public static String toStringHour(int hours, int minutes, int seconds, int millis) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy - HH:mm:ss");

    public static String toStringHour(int hours, int minutes, int seconds, int millis) {
        return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, millis);
    }/*from ww  w .j ava  2 s .c o m*/

    public static synchronized String format(Date date) {
        if (date == null) {
            return null;
        }
        return dateFormat.format(date);
    }

    public static synchronized String format(Calendar calendar) {
        if (calendar == null) {
            return null;
        }
        return dateFormat.format(calendar.getTime());
    }
}

Related

  1. plusHour(int hour)
  2. plusHour(String dateStr, int hour)
  3. plusHours(Date date, int hours)
  4. plusOrMinusHours(Date dateTime, long count)
  5. setHours(Date date, int amount)
  6. toTime(int hours, int minutes, int seconds)
  7. trimToHour(Date date)