de.esprit.common.util

## Class TimeUtil

- java.lang.Object
- - de.esprit.common.util.TimeUtil

-     public class TimeUtil
      extends java.lang.Object

  This is a collection of time oriented utility methods
  Author:
    Rainer Buesch

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DBDate` | `createDate()` Creates a Date object for the current local time.
    `static DBDate` | `createDate(int year, int month, int day)` Creates a date for the given parameters.
    `static DBTime` | `createTime()` Creates a Time object for the current local time.
    `static DBTime` | `createTime(int hour, int minute, int second)` Creates a local time for the given parameters.
    `static DBTimestamp` | `createTimestamp()` Creates a Timestamp object for the current local time.
    `static DBTimestamp` | `createTimestamp(int hour, int minute, int second)` Creates a timestamp (local time) for the given time of the current day.
    `static DBTimestamp` | `createTimestamp(int year, int month, int day, int hour, int minute, int second)` Creates a timestamp (local time) for the given parameters.
    `static DBTimestamp` | `createUtcTimestamp(int year, int month, int day, int hour, int minute, int second)` Creates an UTC timestamp for the given parameters.
    `static DBTimestamp` | `getSameTimeAnotherDay(DBTimestamp startTs, int days)` Returns a new Timestamp rolled forward/backward by the given number of days
    `static java.lang.String` | `toDurationString(long millis)` Converts the given millisecond value to a formatted duration string of the d.hh:mm:ss.
    `static java.lang.String` | `toDurationString(long millis, boolean withSeconds)` Converts the given millisecond value to a formatted duration string.
    `static long` | `toDurationValue(java.lang.String stringValue)` Returns the duration value described by a string of the format d.hh:MM:ss whereas hh or MM are optional
    `static java.lang.String` | `toNeutralFormat(java.util.Date date)` Formats the time value according to 'yyyy-MM-dd'
    `static java.lang.String` | `toNeutralFormat(java.sql.Time time)` Formats the time value according to 'HH:mm:ss'
    `static java.lang.String` | `toNeutralFormat(java.sql.Timestamp ts)` Formats the timestamp value according to 'yyyy-MM-dd HH:mm:ss'
    `static DBTimestamp` | `toUtc(java.sql.Timestamp ts)` Converts the given Timestamp to UTC time.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createUtcTimestamp

          public static DBTimestamp createUtcTimestamp(int year,
                                       int month,
                                       int day,
                                       int hour,
                                       int minute,
                                       int second)

      Creates an UTC timestamp for the given parameters.

    - #### createTimestamp

          public static DBTimestamp createTimestamp(int year,
                                    int month,
                                    int day,
                                    int hour,
                                    int minute,
                                    int second)

      Creates a timestamp (local time) for the given parameters.

    - #### createTimestamp

          public static DBTimestamp createTimestamp(int hour,
                                    int minute,
                                    int second)

      Creates a timestamp (local time) for the given time of the current day.

    - #### createTimestamp

          public static DBTimestamp createTimestamp()

      Creates a Timestamp object for the current local time.

    - #### createTime

          public static DBTime createTime()

      Creates a Time object for the current local time.

    - #### createDate

          public static DBDate createDate()

      Creates a Date object for the current local time.

    - #### createDate

          public static DBDate createDate(int year,
                          int month,
                          int day)

      Creates a date for the given parameters. Note that the time values reflect the current time.

    - #### createTime

          public static DBTime createTime(int hour,
                          int minute,
                          int second)

      Creates a local time for the given parameters. Note that the date values reflect the current date.

    - #### toUtc

          public static DBTimestamp toUtc(java.sql.Timestamp ts)

      Converts the given Timestamp to UTC time.

    - #### toDurationString

          public static java.lang.String toDurationString(long millis,
                                          boolean withSeconds)

      Converts the given millisecond value to a formatted duration string.

    - #### toDurationString

          public static java.lang.String toDurationString(long millis)

      Converts the given millisecond value to a formatted duration string of the d.hh:mm:ss.

    - #### toDurationValue

          public static long toDurationValue(java.lang.String stringValue)

      Returns the duration value described by a string of the format d.hh:MM:ss whereas hh or MM are optional

    - #### getSameTimeAnotherDay

          public static DBTimestamp getSameTimeAnotherDay(DBTimestamp startTs,
                                          int days)

      Returns a new Timestamp rolled forward/backward by the given number of days

    - #### toNeutralFormat

          public static java.lang.String toNeutralFormat(java.sql.Timestamp ts)

      Formats the timestamp value according to 'yyyy-MM-dd HH:mm:ss'

    - #### toNeutralFormat

          public static java.lang.String toNeutralFormat(java.sql.Time time)

      Formats the time value according to 'HH:mm:ss'

    - #### toNeutralFormat

          public static java.lang.String toNeutralFormat(java.util.Date date)

      Formats the time value according to 'yyyy-MM-dd'

Copyright © 2014 EsprIT-Systems. All Rights Reserved.