Java Date Create createDate(final int year, final int month, final int day, final int hour, final int minute, final int second, final int millisecond)

Here you can find the source of createDate(final int year, final int month, final int day, final int hour, final int minute, final int second, final int millisecond)

Description

create Date

License

Open Source License

Declaration

public static synchronized Date createDate(final int year, final int month, final int day, final int hour,
            final int minute, final int second, final int millisecond) 

Method Source Code


//package com.java2s;
/* ===========================================================
 * JStockChart : an extension of JFreeChart for financial market
 * ===========================================================
 *
 * Copyright (C) 2009, by Sha Jiang.//  ww w .j  av  a  2 s. com
 *
 * Project Info:  http://code.google.com/p/jstockchart
 *
 * This library 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 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final Calendar CALENDAR = Calendar.getInstance();

    public static synchronized Date createDate(final int year, final int month, final int day, final int hour,
            final int minute, final int second, final int millisecond) {
        CALENDAR.clear();
        CALENDAR.set(year, month - 1, day, hour, minute, second);
        CALENDAR.set(Calendar.MILLISECOND, millisecond);
        return CALENDAR.getTime();
    }

    public static synchronized Date createDate(final int year, final int month, final int day) {
        createDate(year, month, day, 0, 0, 0, 0);
        return CALENDAR.getTime();
    }

    public static synchronized Date createDate(final int year, final int month, final int day, final int hour) {
        createDate(year, month, day, hour, 0, 0, 0);
        return CALENDAR.getTime();
    }

    public static synchronized Date createDate(final int year, final int month, final int day, final int hour,
            final int minute) {
        createDate(year, month, day, hour, minute, 0, 0);
        return CALENDAR.getTime();
    }

    public static synchronized Date createDate(final int year, final int month, final int day, final int hour,
            final int minute, final int second) {
        createDate(year, month, day, hour, minute, second, 0);
        return CALENDAR.getTime();
    }
}

Related

  1. createDate(final Date date)
  2. createDate(final Date date)
  3. createDate(final int aYear, final int aMonth, final int aDate, final int aHour, final int aMinute, final int aSecond)
  4. createDate(final int day, final int month, final int year)
  5. createDate(final int month, final int day, final int year)
  6. createDate(final int yyyy, final int month, final int day)
  7. createDate(int month, int day)
  8. createDate(int year, int month, int date)
  9. createDate(int year, int month, int date)