Java Calendar Format toInfo(Calendar calendar)

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

Description

to Info

License

Open Source License

Parameter

Parameter Description
calendar a parameter

Declaration

public static String toInfo(Calendar calendar) 

Method Source Code

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

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

public class Main {
    /**/*from   w w w.  j a v a2s .co  m*/
     * @param date
     */
    public static String toInfo(Date date) {
        return toInfo(date, "yyyy-MM-dd HH:mm:ss");
    }

    /**
     * @return
     */
    public static String toInfo() {
        return toInfo(getCalendar().getTime(), "yyyy-MM-dd");
    }

    /**
     * @param date
     * @param dateFromat
     */
    public static String toInfo(Date date, String dateFromat) {
        SimpleDateFormat format = new SimpleDateFormat(dateFromat);
        return format.format(date);
    }

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

    public static long getTime() {
        return getTime(getCalendar());
    }

    public static long getTime(Calendar c) {
        return c.getTimeInMillis();
    }

    public static Calendar getCalendar() {
        return Calendar.getInstance();
    }

    public static String format() {
        return toInfo(getCalendar());
    }
}

Related

  1. formatToHTTPDate(Calendar calendar)
  2. getDate(Calendar cal, String dateFormat)
  3. getDate(Calendar cal, String dateFormat)
  4. print(Calendar[] calendar)
  5. printCalendar(Calendar cal)
  6. toShort(Calendar calendar)
  7. toSimpleFormat(Calendar cal)
  8. toW3C(Calendar cal)