Java TimeZone Get getTime(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, boolean setMillis, int nano)

Here you can find the source of getTime(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, boolean setMillis, int nano)

Description

get Time

License

Open Source License

Declaration

private static long getTime(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute,
            int second, boolean setMillis, int nano) 

Method Source Code

//package com.java2s;
/*/*from w w  w  . ja v a 2 s .  com*/
 *    This program is free software; you can redistribute it and/or modify it under the terms of 
 * the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, 
 * or (at your option) any later version. 
 * 
 *    This program 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 General Public License for more details. 
 *    You should have received a copy of the GNU General Public License along with this program; 
 * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    private static long getTime(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute,
            int second, boolean setMillis, int nano) {
        Calendar c;
        if (tz == null) {
            c = Calendar.getInstance();
        } else {
            c = Calendar.getInstance(tz);
        }
        c.setLenient(lenient);
        if (year <= 0) {
            c.set(Calendar.ERA, GregorianCalendar.BC);
            c.set(Calendar.YEAR, 1 - year);
        } else {
            c.set(Calendar.YEAR, year);
        }
        c.set(Calendar.MONTH, month - 1); // january is 0
        c.set(Calendar.DAY_OF_MONTH, day);
        c.set(Calendar.HOUR_OF_DAY, hour);
        c.set(Calendar.MINUTE, minute);
        c.set(Calendar.SECOND, second);
        if (setMillis) {
            c.set(Calendar.MILLISECOND, nano / 1000000);
        }
        return c.getTime().getTime();
    }
}

Related

  1. getNextHour(final String timezone)
  2. getPossibleUserTimezoneList(int userOffsetInHours)
  3. getRawOffset(String timeZoneStr)
  4. getRawOffsetDifference(TimeZone from, TimeZone to)
  5. getServerTimezoneOffset()
  6. getTime(final String time, final TimeZone tz)
  7. getTime(TimeZone tz, int year, int month, int day, int hour, int minute, int second)
  8. getTime(TimeZone zone)
  9. getTimeAsPerTimeZone(String time, String timeZOne)