Java Timestamp Create toTimestamp(DateTime dt)

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

Description

Null-safe method of converting a DateTime to a Timestamp.

License

Apache License

Return

A UTC DateTime

Declaration

public static Timestamp toTimestamp(DateTime dt) 

Method Source Code


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

import org.joda.time.*;

import java.sql.Timestamp;

public class Main {
    /**/*from  ww w. ja va 2 s . c  o m*/
     * Null-safe method of converting a DateTime to a Timestamp.
     * <br>
     * NOTE: The timestamp also should be in UTC.
     * @return A UTC DateTime
     */
    public static Timestamp toTimestamp(DateTime dt) {
        if (dt == null) {
            return null;
        } else {
            return new Timestamp(dt.getMillis());
        }
    }
}

Related

  1. toTimestamp(BigDecimal value)
  2. toTimestamp(Date date)
  3. toTimestamp(Date date)
  4. toTimestamp(Date date)
  5. toTimeStamp(Date date, String time)
  6. toTimestamp(final Calendar cal)
  7. toTimestamp(final Instant instant)
  8. toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond)
  9. toTimestamp(final java.sql.Date date)