com.sap.sql
Class DateTimeNormalizer

java.lang.Object
  |
  +--com.sap.sql.DateTimeNormalizer

public final class DateTimeNormalizer
extends java.lang.Object

This class can be used to normalize time values that need to be stored via JDBC. Solves the issues with java.sql.Date and java.sql.Time: Both needs to have their millisecond values to be normalized (i.e. the time components must be zero for java.sql.Date and the date component must be '1970-01-01' for java.sql.Time), but fail to do the normalization in their constructor.

Version:
$Id: //tc/jdbi/630_VAL_REL/src/java/com/sap/sql/DateTimeNormalizer.java#1 $

Method Summary
static long normalizeSqlDateMillies(long milliSeconds)
          Normalizes a milli second value according to the specification of java.sql.Date..
static long normalizeSqlTimeMillies(long milliSeconds)
          Normalizes a milli second value according to the specification of java.sql.Time..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

normalizeSqlDateMillies

public static final long normalizeSqlDateMillies(long milliSeconds)
Normalizes a milli second value according to the specification of java.sql.Date.. That is the hour, minute, second and millisecond fields are set to zero according to the VMs default time zone. Typical usage is like:

java.sql.Date birthday = new java.sql.Date(normalizeSqlDateMillies(millis));
Parameters:
milliSeconds - the value to normalize.
Returns:
normalized milli second value.

normalizeSqlTimeMillies

public static final long normalizeSqlTimeMillies(long milliSeconds)
Normalizes a milli second value according to the specification of java.sql.Time.. That is the date fields are set to 01.01.1970 according to the VMs default time zone. Typical usage is like:

java.sql.Time noon = new java.sql.Date(normalizeSqlTimeMillies(millis));
Parameters:
milliSeconds - the value to normalize.
Returns:
normalized milli second value.