Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    /**
     * SimpleDateFormat with pattern yyyy-MM-dd
     */
    private static SimpleDateFormat formatYYYY_MM_DD;

    /**
     * convert calendar to date string with format yyyy-MM-dd
     *
     * @param calendar
     * @return
     */
    public static String calendar2Str(Calendar calendar) {
        return formatYYYY_MM_DD.format(calendar.getTime());
    }
}