Java Calendar to String calendarToString(Calendar c, String format)

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

Description

Convert a calendar to String.

License

Apache License

Parameter

Parameter Description
c a parameter
format a parameter

Return

String

Declaration

public static final String calendarToString(Calendar c, String format) 

Method Source Code

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

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

import java.util.Locale;

public class Main {
    public static final String FORMAT_DATE = "yyyy-MM-dd";

    /**//from   w w w  .ja v a  2  s.c om
     * Convert a calendar to String.
     * 
     * @param c
     * @param format
     * @return String
     */
    public static final String calendarToString(Calendar c, String format) {
        String rtn = null;

        if (c != null) {
            SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.FRANCE);
            rtn = sdf.format(c.getTime());
        }

        return rtn;
    }

    /**
     * Convert a calendar to String.
     * 
     * @param c
     * @return String
     */
    public static final String calendarToString(Calendar c) {
        return calendarToString(c, FORMAT_DATE);
    }
}

Related

  1. calendarParaString(Calendar cal)
  2. calendarToIso(Calendar c)
  3. calendarToSiteDataString(final Calendar cal)
  4. calendarToStorageRoomTimeString(Calendar cal)
  5. calendarToString(Calendar c)
  6. calendarToString(Calendar cal)
  7. calendarToString(Calendar cal)
  8. calendarToString(Calendar cal, String format)
  9. calendarToString(Calendar calendar)