Java Calendar to Time getTime(Calendar calendar)

Here you can find the source of getTime(Calendar calendar)

Description

get Time

License

LGPL

Parameter

Parameter Description
calendar a parameter

Declaration

public static String getTime(Calendar calendar) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

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

public class Main {
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
            "yy/MM/dd HH:mm");

    public static String getTime() {
        return getTime(Calendar.getInstance().getTime());
    }//w w w  .ja  v  a 2s  . com

    /**
     * @param calendar
     * @return
     */
    public static String getTime(Calendar calendar) {
        return getTime(calendar.getTime());
    }

    public static String getTime(long mills) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(mills);
        return simpleDateFormat.format(calendar.getTime());
    }

    public static String getTime(Date date) {
        return simpleDateFormat.format(date);
    }
}

Related

  1. calendarToTimeString(Calendar calendar)
  2. getCalendarStringTime(Calendar c)
  3. getTime(Calendar c)
  4. getTime(Calendar calendar)
  5. getTime(Calendar pCalendar_)
  6. getTimeString(Calendar cal)
  7. getTimeString(Calendar calendar)
  8. printTime(Calendar value)