Java Calendar Format format(Calendar cal, String format)

Here you can find the source of format(Calendar cal, String format)

Description

format

License

Apache License

Declaration

public static String format(Calendar cal, String format) 

Method Source Code


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

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

public class Main {

    public static String format(Date d, String format) {
        if (d == null)
            return "";
        SimpleDateFormat myFormatter = new SimpleDateFormat(format);
        return myFormatter.format(d);
    }//  w  ww  .  ja  v  a  2 s  .c  om

    public static String format(Calendar cal, String format) {
        if (cal == null)
            return "";
        SimpleDateFormat myFormatter = new SimpleDateFormat(format);
        return myFormatter.format(cal.getTime());
    }
}

Related

  1. calToString(Calendar cal)
  2. format(Calendar cal)
  3. format(Calendar cal)
  4. format(Calendar cal, String pattern)
  5. format(Calendar calendar)
  6. format(Calendar calendar)
  7. format(Calendar calendar)