get Calendar Format - Java java.util

Java examples for java.util:Calendar Format

Description

get Calendar Format

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        String format = "java2s.com";
        System.out.println(getCalendarAffichage(calendar, format));
    }/*from   w ww  . j av a2  s.  c o  m*/

    public static String getCalendarAffichage(Calendar calendar,
            String format) {
        final SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(calendar.getTime());

    }
}

Related Tutorials