jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.dbutil
Class Calendar

java.lang.Object
  extended byjava.util.Calendar
      extended byjava.util.GregorianCalendar
          extended byuk.co.weft.dbutil.Calendar
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Calendar
extends java.util.GregorianCalendar

A specialisation of a GregorianCalendar which doesn't make a complete balls-up of rendering itself as a string. I have commented elsewhere on the wanton overcomplication of the Java date handling code... I hope the person who designed it is for ever after forced to keep his diary using the output from GregorianCalendar.toString() as his date format. This class is made slightly more complicated by the need to guess whether a given Calendar represents a date, or a time, or a timestamp. The dancing around with MAXDATESECOND and MAXTIMEYEAR is intended to disambiguate these, but means that Jaquard applications can't reliably deal with instances happening within a few seconds of midnight on years prior to MAXTIMEYEAR. The fundamental problem is that Microsoft SQL Server has no DATE or TIME datatype but only a DATETIME, which it reports to JDBC as a TIMESTAMP (which, of course, it isn't). So we need to decide whether what we're dealing with is really just a date, or, alternatively, really just a time, or both. Unfortunately even if it is really just a date, it will typically be a few milliseconds old by the time we see it. Similarly, a value which is really just a time gets a year value which is typically not zero (but I differs from database engine to database engine). Consequently, I will treat any Calendar object having a time less than Calendar.MAXDATESECONDS past midnight as just being a date, and any Calendar having a year earlier than Calendar.MINTIMEYEAR as just being a time.

Version:
$Revision: 1.9.4.1 $ This revision:
Author:
Simon Brooke (simon, $Author: simon
See Also:
Serialized Form

Field Summary
static int MAXDATESECONDS
          The maximum number of seconds after midnight which we will ignore in considering a Calendar object to represent 'just' a date
static int MAXTIMEYEAR
          The maximum year value we will accept in considering a Calendar to represent 'just' a time
 
Fields inherited from class java.util.GregorianCalendar
AD, BC
 
Fields inherited from class java.util.Calendar
AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
 
Constructor Summary
Calendar()
           
 
Method Summary
 java.lang.String toSQLDateString()
           
 java.lang.String toSQLTimeStampString()
           
 java.lang.String toString()
          Return a sensible, human readable string representing the date/time represented by this Calendar
 
Methods inherited from class java.util.GregorianCalendar
add, computeFields, computeTime, equals, getActualMaximum, getActualMinimum, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, hashCode, isLeapYear, roll, roll, setGregorianChange
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, clone, complete, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, getTimeZone, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, setTimeZone
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXDATESECONDS

public static final int MAXDATESECONDS
The maximum number of seconds after midnight which we will ignore in considering a Calendar object to represent 'just' a date

See Also:
Constant Field Values

MAXTIMEYEAR

public static final int MAXTIMEYEAR
The maximum year value we will accept in considering a Calendar to represent 'just' a time

See Also:
Constant Field Values
Constructor Detail

Calendar

public Calendar()
Method Detail

toSQLDateString

public java.lang.String toSQLDateString()
Returns:
an ANSI SQL string representing the date represented by this Calendar

toSQLTimeStampString

public java.lang.String toSQLTimeStampString()
Returns:
an ANSI SQL String representing the date and/or time represented by this Calendar

toString

public java.lang.String toString()
Return a sensible, human readable string representing the date/time represented by this Calendar


jacquard 1.12.0 by The Web Engineering Factory and Toolworks