Java Timestamp from timestampFromYearMonthDateHourMinuteSecondNanos( int year, int month, int date, int hour, int minute, int second, int nanos)

Here you can find the source of timestampFromYearMonthDateHourMinuteSecondNanos( int year, int month, int date, int hour, int minute, int second, int nanos)

Description

Answer a Timestamp with the year, month, day, hour, minute, second.

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
public static java.sql.Timestamp timestampFromYearMonthDateHourMinuteSecondNanos(
        int year, int month, int date, int hour, int minute,
        int second, int nanos) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution.//w  ww  .  j a v  a2  s .c  o  m
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 *     dminsky - added countOccurrencesOf(Object, List) API
 *     08/23/2010-2.2 Michael O'Brien
 *        - 323043: application.xml module ordering may cause weaving not to occur causing an NPE.
 *                       warn if expected "_persistence_*_vh" method not found
 *                       instead of throwing NPE during deploy validation.
 ******************************************************************************/

public class Main {
    /**
     * Answer a Timestamp with the year, month, day, hour, minute, second.
     * The hour, minute, second are the values calendar uses,
     * i.e. year is from 0, month is 0-11, date is 1-31, time is 0-23/59.
     */
    @SuppressWarnings("deprecation")
    public static java.sql.Timestamp timestampFromYearMonthDateHourMinuteSecondNanos(
            int year, int month, int date, int hour, int minute,
            int second, int nanos) {
        // This was not converted to use Calendar for the conversion because calendars do not take nanos.
        // but it should be, and then just call setNanos.
        return new java.sql.Timestamp(year - 1900, month, date, hour,
                minute, second, nanos);
    }
}

Related

  1. convertToTimestampDate(Date date)
  2. convertToTimestampHMS(String dateData)
  3. getFirstTimeOfDay(Calendar calendar)
  4. timestampFromCalendar(Calendar calendar)
  5. timestampFromLong(long t)