Java Today formatToday()

Here you can find the source of formatToday()

Description

format Today

License

Apache License

Declaration

public static String formatToday() 

Method Source Code

//package com.java2s;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * Copyright 2013 Joseph Yuan/*from   www.j  a va 2s. co  m*/
 *
 * 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 formatToday() {
        return formatDate("MM.dd.yy", 0, 0, 0);
    }

    public static String formatToday(String format) {
        return formatDate(format, 0, 0, 0);
    }

    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. createTodayDirectory(File destDir, String inputFileName)
  2. createTodayPrefixedDirectory(final String prefix, final File parent)
  3. deletePreviousDay(Calendar today, String temppath)
  4. endOfToday()
  5. formatToday()
  6. formatToDays(Date date)
  7. getAllToday()
  8. getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate)
  9. getCalendarTodayZero(Calendar today)