Here you can find the source of formatDate(Calendar c)
public static String formatDate(Calendar c)
//package com.java2s; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright 2013 Joseph Yuan//from www .jav a 2 s. com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String formatDate(String format, int offset_years, int offset_months, int offset_days) { Calendar date = Calendar.getInstance(); date.add(Calendar.YEAR, offset_years); date.add(Calendar.MONTH, offset_months); date.add(Calendar.DATE, offset_days); return formatDate(format, date); } public static String formatDate(Calendar c) { return (new SimpleDateFormat("MM.dd.yy")).format(c.getTime()); } public static String formatDate(String format, Calendar c) { return (new SimpleDateFormat(format)).format(c.getTime()); } }