Java Timestamp Create toSQLTimestamp(DateTime dt)

Here you can find the source of toSQLTimestamp(DateTime dt)

Description

to SQL Timestamp

License

Apache License

Declaration

public static java.sql.Timestamp toSQLTimestamp(DateTime dt) 

Method Source Code

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

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import org.joda.time.LocalDateTime;

public class Main {
    public static java.sql.Timestamp toSQLTimestamp(DateTime dt) {
        // TODO - confirm this conversion always works, esp. across timezones
        java.sql.Timestamp ts = (dt == null ? null : new java.sql.Timestamp(dt.getMillis()));
        return ts;
    }//from w w  w  .  j  a  v  a2  s.  co  m

    public static java.sql.Timestamp toSQLTimestamp(LocalDateTime ldt) {
        // TODO - confirm this conversion always works, esp. across timezones
        java.sql.Timestamp ts = (ldt == null ? null : new java.sql.Timestamp(ldt.toDateTime().getMillis()));
        return ts;
    }

    public static DateTime toDateTime(java.sql.Timestamp ts) {
        // TODO - confirm this conversion always works, esp. across timezones
        DateTime dt = (ts == null ? null : new DateTime(ts));
        return dt;
    }

    public static DateTime toDateTime(java.util.Date d) {
        // TODO - confirm this conversion always works, esp. across timezones
        DateTime dt = (d == null ? null : new DateTime(d));
        return dt;
    }

    public static DateTime toDateTime(java.sql.Timestamp ts, String timeZoneID) {
        // TODO - confirm this conversion always works, esp. across timezones
        DateTime dt = (ts == null ? null : new DateTime(ts, DateTimeZone.forID(timeZoneID)));
        return dt;
    }

    public static DateTime toDateTime(java.util.Date d, String timeZoneID) {
        // TODO - confirm this conversion always works, esp. across timezones
        DateTime dt = (d == null ? null : new DateTime(d, DateTimeZone.forID(timeZoneID)));
        return dt;
    }
}

Related

  1. toSQLTime(Instant timestamp)
  2. toSqlTime(Timestamp timestamp)
  3. toSqlTimestamp(Date d)
  4. toSqlTimeStamp(Date d)
  5. toSQLTimestamp(Date date)
  6. toSqlTimestamp(java.util.Date date)
  7. toSQLTimestamp(Object object, Object oDefault)
  8. toSQLTimestamp(String time)
  9. toTimestamp(BigDecimal value)