Java Calendar to Time getTime(Calendar calendar)

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

Description

get Time

License

Apache License

Parameter

Parameter Description
calendar a parameter

Declaration

public static String getTime(Calendar calendar) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String getTime() {
        return getTime(Calendar.getInstance().getTime());
    }/* ww w.  j  a  v  a 2s.  co  m*/

    /**
     * @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);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy/MM/dd HH:mm");
        return simpleDateFormat.format(calendar.getTime());
    }

    public static String getTime(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy/MM/dd HH:mm");
        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)