Java Calendar Format formatDate(Calendar c)

Here you can find the source of formatDate(Calendar c)

Description

format Date

License

Apache License

Declaration

public static String formatDate(Calendar c) 

Method Source Code

//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());
    }
}

Related

  1. formatCalendar(Calendar calendar)
  2. formatCalendar(Calendar objCal, String strFormat)
  3. formatCalendarTS(Calendar value)
  4. formatCalendarXsdZulu(Calendar c, int millisDigits)
  5. formatDate(Calendar c)
  6. formatDate(Calendar c)
  7. formatDate(Calendar cal)
  8. formatDate(Calendar cal)
  9. formatDate(Calendar cal)