Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * This file is part of the au-xml-util package
 *
 * Copyright Trenton D. Adams <trenton daught d daught adams at gmail daught ca>
 * 
 * au-xml-util is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * au-xml-util is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with au-xml-util.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * See the COPYING file for more information.
 */

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    /**
     * Converts the "now" calendar into xs:date format by calling {@link
     * #xsDateFormat(Calendar)}
     *
     * @return the new format yyyy-MM-dd
     */
    public static String xsDateFormatNow() {
        return xsDateFormat(Calendar.getInstance());
    }

    /**
     * Converts the calendar into a string formated according to the xs:date
     * format.
     *
     * @param calendar the calendar to convert, must not be null
     *
     * @return the new format yyyy-MM-dd
     */
    public static String xsDateFormat(final Calendar calendar) {
        final SimpleDateFormat dateFormat;

        dateFormat = new SimpleDateFormat("yyyy-MM-dd");

        return dateFormat.format(calendar.getTime());
    }
}