at.glawar
GlawarDate [2006-07-04]

at.glawar.gladate
Class GLADate

java.lang.Object
  extended byat.glawar.gladate.GLADate

public class GLADate
extends Object

This class deals with date methods.

If TIME is used, this class always uses the TimeZone Europe/Vienna. That means that HOUR's range is from 0 to 23, MINUTE's and SECOND's range is from 0 to 59 and MILLISECOND's range is from 0 to 999.

Since:
GLADate 0.9
Version:
$Revision: 1.9 $ ($Date: 2006/07/04 18:49:25 $)
Author:
DI Franz-Peter Glawar last modified by: $Author: frahunz $, software.glawar.at

Constructor Summary
GLADate()
           
 
Method Summary
static Date castSQL2UtilDate(Date dValue)
          cast a java.util.Date out from a java.sql.Date.
static Date castUtil2SQLDate(Date dValue)
          cast a java.sql.Date out from a java.util.Date.
static String Date2String(Date dValue)
          formats a date-value to a string (but only the date).
static String Date2String(Date dValue, boolean isFullLength, String strSeparator)
          formats a date-value to a string (but only the date).
static String Date2String(Date dValue, String strSeparator)
          formats a date-value to a string (but only the date).
static String Date2StringReverse(Date dValue)
          formats a date-value to a string.
static String Date2StringReverse(Date dValue, boolean isFullLength, String strSeparator)
          formats a date-value to a string.
static String Date2StringReverse(Date dValue, String strSeparator)
          formats a date-value to a string.
static String formatDateYYYY_Minus_MM_Minus_DD(Date dValue)
          format a given date-value into a string yyyy-mm-dd.
static String formatSQLDate2OracleParam(Date date, String patternJava, String patternOracle)
          create String that is necessary to write a Date-value into an Oracle database.
static String getDateEntry()
          get actual date inf form of yyyy-mm-dd HH:MM:SS.
static Date getToday()
          get actual date and time
static Date getTodayWithoutTime()
          get actual date and time 00:00:00:000.
static Date getTomorrow()
          get tomorrow's date with actual time.
static Date getTomorrowWithoutTime()
          get tomorrow's date with time 00:00:00:000.
static Date getYesterday()
          get yesterday's date with actual time.
static Date getYesterdayWithoutTime()
          get yesterday's date with time 00:00:00:000.
static boolean isDayBeforeToday(Date dValue)
          This method checks if the given date is before the actual day (today).
static boolean isSameDay(Date dValue1, Date dValue2)
          tests, if the date of two java.util.Date-values are equal.
static boolean isUndefinedJavaDate(Date date)
          checks if the given date is an undefined java date.
static Date makeTimeFromString(Object obj)
          makes a java.util.Date of an object.
static String makeTodayString()
          make a string of todays date and time
static Date set2NoTime(Date dValue)
          set the actual date to time 00:00:00:000.
static Date setDate(int iDay, int iMonth, int iYear)
          sets only date, the time will be set to 00:00:00:000.
static Date setDate2Time(Date dValue, int iHour, int iMinute, int iSecond, int iMiliSecond)
          set a java.utilDate to a special time
static Date setDateAndTime(int iDay, int iMonth, int iYear, int iHour, int iMin, int iSec, int iMilliSec)
          sets date and time.
static Date setUndefinedOracleDate()
          set a date-value that identifies Oracle as undefined
static Date setUndefinedOracleDateWithoutTime()
          set a date-vale that identifies Oracle as undefined plus time 00:00:00:000.
static Date String2Date(String strDate)
          formats a given date-string into a date
static Date String2Date(String strDate, boolean bWithTime)
          formats a given date-string
static String Time2String(Date dValue)
          formats a date-value to a string (but only the time).
static String Time2String(Date dValue, boolean isFullLength, String strSeparator)
          formats a date-value to a string (but only the time).
static String Time2String(Date dValue, String strSeparator)
          formats a date-value to a string (but only the time).
static String toRFC822String()
          return the actual date-value as an RFC-822.
static String toRFC822String(Date dValue)
          return the given date-value as an RFC-822.
static String toTimeDifference(long lValue)
          formats the given time period in miliseconds to a timedifference to GMT.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLADate

public GLADate()
Method Detail

castUtil2SQLDate

public static Date castUtil2SQLDate(Date dValue)

cast a java.sql.Date out from a java.util.Date.

Parameters:
dValue - the java.util.Date to cast to
Returns:
the casted java.sql.Date
Since:
GLADate 2.1

castSQL2UtilDate

public static Date castSQL2UtilDate(Date dValue)

cast a java.util.Date out from a java.sql.Date.

Parameters:
dValue - the java.sql.Date to cast to
Returns:
the casted java.util.Date
Since:
GLADate 2.1

Time2String

public static String Time2String(Date dValue,
                                 boolean isFullLength,
                                 String strSeparator)
formats a date-value to a string (but only the time).

Parameters:
dValue - java.util.Date-value that should be formatted
isFullLength - if set to true it means that not an empty string will be returned if dValue is null but a string of length 10
strSeparator - the separator between the values, if null the standard-separator will be taken, which is :; this parameter's max length is 1!
Returns:
either a string of length 0 or 12 if dValue is null (depending on the parameter isFullLength) or the formatted date HH:MM:SS:mmm
Since:
GLADate 0.9

Time2String

public static String Time2String(Date dValue)
formats a date-value to a string (but only the time).

Parameters:
dValue - java.util.Date-value that should be formatted
Returns:
a string of length 0 if dValue is null or the formatted date HH:MM:SS:mmm
Since:
GLADate 0.9

Time2String

public static String Time2String(Date dValue,
                                 String strSeparator)
formats a date-value to a string (but only the time).

Parameters:
dValue - java.util.Date-value that should be formatted
strSeparator - the separator between the values, if null the standard-separator will be taken, which is :; this parameter's max length is 1!
Returns:
a string of length 0 if dValue is null or the formatted date HH:MM:SS:mmm
Since:
GLADate 0.9

Date2String

public static String Date2String(Date dValue,
                                 boolean isFullLength,
                                 String strSeparator)
formats a date-value to a string (but only the date).

Parameters:
dValue - java.util.Date-value that should be formatted
isFullLength - if set to true it means that not an empty string will be returned if dValue is null but a string of length 10
strSeparator - the separator between the values, if null the standard-separator will be taken, which is .; this parameter's max length is 1!
Returns:
either a string of length 0 or 10 if dValue is null (depending on the parameter isFullLength) or the formatted date dd.mm.yyyy
Since:
GLADate 0.9

Date2String

public static String Date2String(Date dValue)
formats a date-value to a string (but only the date).

Parameters:
dValue - java.util.Date-value that should be formatted
Returns:
either a string of length 0 if dValue is null or the formatted date dd.mm.yyyy
Since:
GLADate 0.9

Date2String

public static String Date2String(Date dValue,
                                 String strSeparator)
formats a date-value to a string (but only the date).

Parameters:
dValue - java.util.Date-value that should be formatted
strSeparator - the separator between the values, if null the standard-separator will be taken, which is .; this parameter's max length is 1!
Returns:
either a string of length 0 if dValue is null or the formatted date dd.mm.yyyy
Since:
GLADate 0.9

Date2StringReverse

public static String Date2StringReverse(Date dValue,
                                        boolean isFullLength,
                                        String strSeparator)
formats a date-value to a string.

Parameters:
dValue - java.util.Date-value that should be formatted
isFullLength - if set to true it means that not an empty string will be returned if dValue is null but a string of length 10
strSeparator - the separator between the values, if null the standard-separator will be taken, which is .; this parameter's max length is 1!
Returns:
either a string of length 0 or 10 if dValue is null (depending on the parameter isFullLength) or the formatted date yyyy.mm.dd
Since:
GLADate 0.9

Date2StringReverse

public static String Date2StringReverse(Date dValue,
                                        String strSeparator)
formats a date-value to a string.

Parameters:
dValue - java.util.Date-value that should be formatted
strSeparator - the separator between the values, if null the standard-separator will be taken, which is .; this parameter's max length is 1!
Returns:
either a string of length 0 if dValue is null or the formatted date yyyy.mm.dd
Since:
GLADate 0.9

Date2StringReverse

public static String Date2StringReverse(Date dValue)
formats a date-value to a string.

Parameters:
dValue - java.util.Date-value that should be formatted
Returns:
either a string of length 0 if dValue is null or the formatted date yyyy.mm.dd
Since:
GLADate 0.9

setDateAndTime

public static Date setDateAndTime(int iDay,
                                  int iMonth,
                                  int iYear,
                                  int iHour,
                                  int iMin,
                                  int iSec,
                                  int iMilliSec)

sets date and time.

Parameters:
iDay - day
iMonth - month
iYear - year
iHour - hour
iMin - minute
iSec - second
iMilliSec - millisecond
Returns:
a java.util.Date
Since:
GLADate 0.9

setDate

public static Date setDate(int iDay,
                           int iMonth,
                           int iYear)
sets only date, the time will be set to 00:00:00:000.

Parameters:
iDay - day
iMonth - month
iYear - year
Returns:
a valid java.util.Date with time 00:00:00:000
Since:
GLADate 0.9

makeTimeFromString

public static Date makeTimeFromString(Object obj)
makes a java.util.Date of an object.

Parameters:
obj - String containing hh:mm
Returns:
a java.util.Date with time that has been specified and date (1.1.1970); if an error occured the time will be 01:00:00:0000
Since:
GLADate 0.9

setDate2Time

public static Date setDate2Time(Date dValue,
                                int iHour,
                                int iMinute,
                                int iSecond,
                                int iMiliSecond)
set a java.utilDate to a special time

Parameters:
dValue - the java.util.Date to set
iHour - hour to set
iMinute - minute to set
iSecond - second to set
iMiliSecond - millisecond to set
Returns:
either null if the dValue was null or the original date plus the set time
Since:
GLADate 0.9

set2NoTime

public static Date set2NoTime(Date dValue)
set the actual date to time 00:00:00:000.

Parameters:
dValue - the java.util.Date to set to no time
Returns:
if dValue contains a valid java.util.Date it returns the date but with time 00:00:00:000
Since:
GLADate 0.9

setUndefinedOracleDate

public static Date setUndefinedOracleDate()
set a date-value that identifies Oracle as undefined

Returns:
a date which identifies Oracle as undefined
Since:
GLADate 1.0

setUndefinedOracleDateWithoutTime

public static Date setUndefinedOracleDateWithoutTime()
set a date-vale that identifies Oracle as undefined plus time 00:00:00:000.

Returns:
a date which identifies Oracle as undefined and time is set to 00:00:00:000
Since:
GLADate 0.9

isUndefinedJavaDate

public static boolean isUndefinedJavaDate(Date date)
checks if the given date is an undefined java date.

Parameters:
date - Date-value to check
Returns:
true if the parameter is the default date value in java (01.01.1970), otherwise false
Since:
GLADate 0.9

getToday

public static Date getToday()
get actual date and time

Returns:
actual date and time
Since:
GLADate 0.9

getTodayWithoutTime

public static Date getTodayWithoutTime()
get actual date and time 00:00:00:000.

Returns:
actual date but time is 00:00:00:000
Since:
GLADate 0.9

getYesterday

public static Date getYesterday()
get yesterday's date with actual time.

Returns:
the same Date-value (with time) but yesterday
Since:
GLADate 0.9

getYesterdayWithoutTime

public static Date getYesterdayWithoutTime()
get yesterday's date with time 00:00:00:000.

Returns:
the same Date-value (with time 00:00:00:000) but yesterday
Since:
GLADate 0.9

getTomorrow

public static Date getTomorrow()
get tomorrow's date with actual time.

Returns:
the same Date-value (with time) but tomorrow
Since:
GLADate 0.9

getTomorrowWithoutTime

public static Date getTomorrowWithoutTime()
get tomorrow's date with time 00:00:00:000.

Returns:
the same Date-value (with time 00:00:00:000) but tomorrow
Since:
GLADate 0.9

formatSQLDate2OracleParam

public static String formatSQLDate2OracleParam(Date date,
                                               String patternJava,
                                               String patternOracle)
create String that is necessary to write a Date-value into an Oracle database.

Parameters:
date - the java.util.Date to write into Oracle database
patternJava - e. g. dd-MM-yyyy HH:mm
patternOracle - e. g. dd-mm-yyyy hh24:mi
Returns:
the formatted string that writes the date-value into the oracle database
Since:
GLADate 0.9

isSameDay

public static boolean isSameDay(Date dValue1,
                                Date dValue2)

tests, if the date of two java.util.Date-values are equal.

The time is not checked!

If both date-values are null, this method also returns true

Parameters:
dValue1 - date1
dValue2 - date2
Returns:
true if the dates are equal, false otherwise
Since:
GLADate 0.9

String2Date

public static Date String2Date(String strDate)
formats a given date-string into a date

Parameters:
strDate - string representing a valid date (yyyyMMdd)
Returns:
Date-representation
Since:
GLADate 0.9

String2Date

public static Date String2Date(String strDate,
                               boolean bWithTime)
formats a given date-string

Parameters:
strDate - string representing a valid date
bWithTime - if true strDate will be yyyyMMddHHmmss else strDate will be yyyyMMdd
Returns:
Date-representation
Since:
GLADate 0.9

makeTodayString

public static String makeTodayString()
make a string of todays date and time

Returns:
yyyy-mm-dd HH:MM:SS

isDayBeforeToday

public static final boolean isDayBeforeToday(Date dValue)

This method checks if the given date is before the actual day (today).

Parameters:
dValue - date to check
Returns:
true if the given date is before today, false otherwise and also if dValue is null
Since:
2006-03-10

getDateEntry

public static String getDateEntry()

get actual date inf form of yyyy-mm-dd HH:MM:SS.

Returns:
actual date as yyyy-mm-dd HH:MM:SS
Since:
2006-04-02

formatDateYYYY_Minus_MM_Minus_DD

public static final String formatDateYYYY_Minus_MM_Minus_DD(Date dValue)

format a given date-value into a string yyyy-mm-dd.

what ... more information
original author DI Franz-Peter Glawar
last modified by FP

Parameters:
dValue - java.util.Date to format
Returns:
null if dValue is null otherwise the date formatted as yyyy-mm-dd
Since:
2006-03-21

toTimeDifference

public static final String toTimeDifference(long lValue)

formats the given time period in miliseconds to a timedifference to GMT.

Parameters:
lValue - time in milliseconds
Returns:
either GMT if lValue is 0 otherwise the difference in + or - and then HHMM (e. g. +0230)
Since:
2006-07-03

toRFC822String

public static final String toRFC822String()

return the actual date-value as an RFC-822.

Returns:
RFC-822 (e. g. Sun, 02 Jul 2006 16:04:00 +0200)
Since:
2006-07-03

toRFC822String

public static final String toRFC822String(Date dValue)

return the given date-value as an RFC-822.

Parameters:
dValue - valid date
Returns:
RFC-822 (e. g. Sun, 02 Jul 2006 16:04:00 +0200)
Since:
2006-07-03

software.glawar.at

Developed by software.glawar.at