Converts the given calendar object to a string according to one predefined format - Android java.util

Android examples for java.util:Calendar Format

Description

Converts the given calendar object to a string according to one predefined format

Demo Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

public class Main {
    /**//www  .j a  v a  2s  .c om
     * Converts the given calendar object to a string according to one predefined format
     * 
     * @param a_givenDate -> given month
     * @return String -> calendar object formated to string
     */
    public static String dateForCalendarControl(Calendar a_givenDate) {
        String l_format = "yyyyMMdd";

        SimpleDateFormat l_sdf = new SimpleDateFormat(l_format,
                Locale.getDefault());
        return l_sdf.format(a_givenDate.getTime());
    }
}

Related Tutorials