com.sapportals.htmlb.type

Class Date

java.lang.Object
  extended bycom.sapportals.htmlb.type.Date
All Implemented Interfaces:
Comparable, Serializable

public class Date
extends Object
implements Comparable, Serializable

Special Date class for htmlb to avoid time zone conflicts and confusion with times

Copyright 2004 SAP AG

See Also:
Serialized Form

Field Summary
protected static int[] max_days_per_month
           
 
Constructor Summary
Date()
          Constructs new Date object and initializes it with the current date.
Date(int year, int month, int day)
          Constructs a new Date object and initializes it with the given parameters.
Date(long millisSinceEpoch)
          Constructs a new Date object and initializes it with the given parameters.
Date(String dateString)
          Constructs new Date object and initializes it with the given dateString.
 
Method Summary
 int compareTo(Object o)
          Compares this date with given object.
 boolean equals(Object dateObject)
          Compares given dateObject with contained date.
 int getDay()
          Returns contained day.
 int getMonth()
          Returns contained month.
 Date getUtilDate()
          Returns a java.util.Date object representing the same date.
 int getYear()
          Returns contained year as absolute year i.e. 1987 will be returned instead of e.g. 87.
static boolean isLeapYear(int year)
          Checks whether the given year is a leap year.
 boolean isValid()
          Informs about the state of the Date object.
 void set(Date utilDate)
           
 void set(long millisSinceEpoch)
           
 void set(String dateString)
           
 String toShortString()
          Returns the contained date as a string in the format YYYYMMDD.
 String toString()
          Returns the contained date as a string in the format YYYY-MM-DD.
 String toString(boolean useShort)
          Returns the contained date as a string in the format YYYY-MM-DD if useShort is false or YYYYMMDD if useShort is true;
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

max_days_per_month

protected static int[] max_days_per_month
Constructor Detail

Date

public Date()
Constructs new Date object and initializes it with the current date.


Date

public Date(int year,
            int month,
            int day)
Constructs a new Date object and initializes it with the given parameters.


Date

public Date(long millisSinceEpoch)
Constructs a new Date object and initializes it with the given parameters.


Date

public Date(String dateString)
Constructs new Date object and initializes it with the given dateString. dateString may have one of these formats:

Method Detail

set

public void set(Date utilDate)

set

public void set(long millisSinceEpoch)

set

public void set(String dateString)

isLeapYear

public static boolean isLeapYear(int year)
Checks whether the given year is a leap year.


toString

public String toString()
Returns the contained date as a string in the format YYYY-MM-DD.


toString

public String toString(boolean useShort)
Returns the contained date as a string in the format YYYY-MM-DD if useShort is false or YYYYMMDD if useShort is true;

Parameters:
useShort - true if the String shouldn't contain '-'
Returns:
a String format for this Date.

toShortString

public String toShortString()
Returns the contained date as a string in the format YYYYMMDD.


equals

public boolean equals(Object dateObject)
Compares given dateObject with contained date. dateObject must be of type com.sapportals.htmlb.type.Date.
Returns true if both dates are the same i.e. year, month and day match.
Returns false else.


compareTo

public int compareTo(Object o)
              throws ClassCastException
Compares this date with given object. If the argument is not an instance of type com.sapportals.htmlb.type.Date or null this method throws a ClassCastException, else it returns -1, 0 or 1 if this date is earlier, same or later then the given date as argument. Returns -2 if this date is invalid. Returns -3 if given date is invalid.

Specified by:
compareTo in interface Comparable
Throws:
ClassCastException

getYear

public int getYear()
Returns contained year as absolute year i.e. 1987 will be returned instead of e.g. 87.


getMonth

public int getMonth()
Returns contained month. Months start with 1 (January) up to 12 (December).


getDay

public int getDay()
Returns contained day. Days start with 1.


getUtilDate

public Date getUtilDate()
Returns a java.util.Date object representing the same date.


isValid

public boolean isValid()
Informs about the state of the Date object. Date objects can be invalid due to following reasons:
  1. Illegal date value in construtor



Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.