Java Timestamp Create toTimestamp(Date date)

Here you can find the source of toTimestamp(Date date)

Description

to Timestamp

License

Open Source License

Declaration

public static Timestamp toTimestamp(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;

import java.time.LocalDateTime;

import java.time.ZoneId;

import java.util.Date;

public class Main {
    public static Timestamp toTimestamp(Date date) {
        return toTimestamp(toLocalDateTime(date));
    }//w  w w . ja v  a2  s. co m

    public static Timestamp toTimestamp(LocalDateTime date) {
        return Timestamp.valueOf(date);
    }

    public static LocalDateTime toLocalDateTime(Date date) {
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
    }
}

Related

  1. toSqlTimestamp(java.util.Date date)
  2. toSQLTimestamp(Object object, Object oDefault)
  3. toSQLTimestamp(String time)
  4. toTimestamp(BigDecimal value)
  5. toTimestamp(Date date)
  6. toTimestamp(Date date)
  7. toTimeStamp(Date date, String time)
  8. toTimestamp(DateTime dt)
  9. toTimestamp(final Calendar cal)