com.sap.sql

Class DateTimeNormalizer

java.lang.Object
  extended by com.sap.sql.DateTimeNormalizer

public final class DateTimeNormalizer
extends 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.


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.
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] ENGFACADE [sap.com] tc/je/opensql/api api BC-JAS
[sap.com] ENGINEAPI [sap.com] opensqldeprecated default BC-JAS-PER-SQL
[sap.com] CORE-TOOLS [sap.com] com.sap.engine.client.libdeprecated default BC-JAS


Copyright 2012 SAP AG Complete Copyright Notice