Java Timestamp Create toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond)

Here you can find the source of toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond)

Description

to Timestamp

License

Apache License

Declaration

public static Timestamp toTimestamp(final int year, final int month, final int dayOfMonth, final int hour,
            final int minute, final int second, final int millsecond) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.util.Calendar;

import java.util.Date;

public class Main {
    public static Timestamp toTimestamp(final int year, final int month, final int dayOfMonth, final int hour,
            final int minute, final int second, final int millsecond) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month - 1, dayOfMonth, hour, minute, second);
        cal.set(Calendar.MILLISECOND, millsecond);

        return new Timestamp(cal.getTimeInMillis());
    }//from   w  w  w.j a  v a 2  s  . c  om

    public static Timestamp toTimestamp(final Date date) {
        return new Timestamp(date.getTime());
    }
}

Related

  1. toTimestamp(Date date)
  2. toTimeStamp(Date date, String time)
  3. toTimestamp(DateTime dt)
  4. toTimestamp(final Calendar cal)
  5. toTimestamp(final Instant instant)
  6. toTimestamp(final java.sql.Date date)
  7. toTimestamp(final String pValue)
  8. toTimestamp(java.sql.Date date)
  9. toTimestamp(long ts)