Java SQL LocalDate toJavaDate(DateMidnight dm)

Here you can find the source of toJavaDate(DateMidnight dm)

Description

to Java Date

License

Apache License

Declaration

public static java.util.Date toJavaDate(DateMidnight dm) 

Method Source Code


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

import org.joda.time.DateMidnight;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;

public class Main {
    public static java.util.Date toJavaDate(DateMidnight dm) {
        // TODO - confirm this conversion always works, esp. across timezones
        java.util.Date d = (dm == null ? null : new java.util.Date(dm.getMillis()));
        return d;
    }// w  ww .j  a va2 s.c  o  m

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

    public static java.util.Date toJavaDate(LocalDate ld) {
        // TODO - confirm this conversion always works, esp. across timezones
        java.util.Date d = (ld == null ? null : new java.util.Date(ld.toDateTimeAtStartOfDay().getMillis()));
        return d;
    }

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

    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. setDate(PreparedStatement s, int col, LocalDate ld)
  2. toDate(LocalDate localDate)
  3. toDate(LocalDate localDate)
  4. toDate(LocalDate localDate)
  5. toInstant(Date date)
  6. toJDBC(LocalDate fecha)
  7. toLocalDate(Date date)
  8. toLocalDate(Date date)
  9. toLocalDate(final Date d)