Java Timestamp Convert To toDateTime(Timestamp value)

Here you can find the source of toDateTime(Timestamp value)

Description

Null-safe method of converting a SQL Timestamp into a DateTime that it set specifically to be in UTC.

License

Apache License

Return

A UTC DateTime

Declaration

public static DateTime toDateTime(Timestamp value) 

Method Source Code


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

import org.joda.time.*;

import java.sql.Timestamp;

public class Main {
    /**//  ww w  .  j  a  v  a2s  .co  m
     * Null-safe method of converting a SQL Timestamp into a DateTime that
     * it set specifically to be in UTC.
     * <br>
     * NOTE: The timestamp also should be in UTC.
     * @return A UTC DateTime
     */
    public static DateTime toDateTime(Timestamp value) {
        if (value == null) {
            return null;
        } else {
            return new DateTime(value.getTime(), DateTimeZone.UTC);
        }
    }
}

Related

  1. toCalendar(java.sql.Timestamp stamp)
  2. toCalendar(Timestamp stamp)
  3. toCalendar(Timestamp timestamp)
  4. toDate(java.sql.Timestamp timestamp)
  5. toDate(Timestamp timestamp)
  6. toDecimal(Timestamp instant)
  7. toEnglishDateTime(java.sql.Timestamp ts)
  8. toEnglishHours(java.sql.Timestamp ts)
  9. toEPICSTime(java.sql.Timestamp timestamp)