Java Hour Format formatDateTime(final Calendar cal)

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

Description

format Date Time

License

Open Source License

Declaration

public static String formatDateTime(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;

public class Main {
    public static String formatDateTime(final long date) {
        if (date < 0) {
            throw new IllegalArgumentException("date");
        }/*from  ww w .j  av  a  2  s . c  om*/

        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date);
        return formatDateTime(cal);
    }

    public static String formatDateTime(final Calendar cal) {
        if (cal == null) {
            throw new NullPointerException("cal");
        }

        DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        return formatter.format(cal.getTime());
    }
}

Related

  1. formatDateTime(Date date)
  2. formatDatetime(Date date)
  3. formatDateTime(Date date)
  4. formatDateTime(Date dateTime)
  5. formatDateTime(Date myDate)
  6. formatDateTime(final Date dat)
  7. formatDateTime(final Date date)
  8. formatDateTime(java.util.Date d)
  9. formatDateTime(java.util.Date date)