Java Hour Format formatTime(final Calendar cal)

Here you can find the source of formatTime(final Calendar cal)

Description

format Time

License

Open Source License

Declaration

public static String formatTime(final Calendar cal) 

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 {
    public static String formatTime(final Calendar cal) {
        if (cal == null) {
            throw new NullPointerException("cal");
        }//from  w w w  . j  av  a  2 s . c om

        return formatTime(cal.getTime());
    }

    public static String formatTime(final Date date) {
        if (date == null) {
            throw new NullPointerException("date");
        }

        DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(date);
    }
}

Related

  1. formatTime(Date date)
  2. formatTime(Date date)
  3. formatTime(Date time)
  4. formatTime(Date time)
  5. formatTime(double s)
  6. formatTime(final Date date)
  7. formatTime(final long time)
  8. formatTime(int msec, String format)
  9. formatTime(java.util.Date date)