Java Doc for Dates.java in  » Ajax » zk » org » zkoss » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » zk » org.zkoss.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.zkoss.util.Dates

Dates
public class Dates (Code)
Utilities for java.util.Date
author:
   henrichen
author:
   tomyeh




Method Summary
final public static  Dateadd(Date when, TimeZone tz, int field, int amount)
     Date Arithmetic function.
final public static  DatebeginOfDate(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the beginning date of the specified date and TimeZone.
final public static  DatebeginOfMonth()
     Return the beginning date of this month.
final public static  DatebeginOfMonth(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone.
final public static  DatebeginOfYear()
     Return the beginning date of this year.
final public static  DatebeginOfYear(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone.
final public static  intdayMonthOfDate(Date when, TimeZone tz)
     Get the day of month of a date.
final public static  DateendOfDate(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the last millisecond date of the specified date and TimeZone.
final public static  DateendOfMonth()
     Return the ending date of this month.
final public static  DateendOfMonth(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone.
final public static  DateendOfYear()
     Return the ending date of this year.
final public static  DateendOfYear(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone.
final public static  booleanisBeginOfMonth(Date when, TimeZone tz)
     Whether the given date in the specified TimeZone is the first day of that month.
final public static  booleanisEndOfMonth(Date when, TimeZone tz)
     Whether the given date in the specified TimeZone is the last day of that month.
final public static  booleanisRounded(Date date, int precision)
     Tests whether a date is rounded.
final public static  intlocalizedYearOfDate(Date when, Locale locale, TimeZone tz)
     Get the year of a date in the specified locale.

Currenty, only Locale.ZH_TW is supported, i.e., "year - 1911" and it's may be less than 0.

final public static  Datemerge(Date datePart, Date timePart, TimeZone tz)
     merge the date part and time part of two specified dates into a date.
final public static  intmonthOfDate(Date when, TimeZone tz)
     Get the month of a date.
final public static  intmonthOfDatePlus1(Date when, TimeZone tz)
     Get the month of a date.
final public static  Datenow(int precision)
     Returns the current time but rounding to the specified precision of milliseconds.
final public static  Datenow()
     Returns the current time without rounding.
final public static  DatepreviousDate(Date when)
     Given a date, return the previouse date of the given date (24 hrs before).
final public static  Dateround(Date date, int precision)
     Truncates date to the nearest precision milliseconds.
final public static  longround(long time, int precision)
     Rounds a date represented in long to the specified precision of milliseconds.
Parameters:
  time - the date represented in long.
Parameters:
  precision - the divider of the precision(e.g.
final public static  longsubtract(Date date2, TimeZone tz, int field, Date date1)
     Date Arithmetic function (date2 - date1).
final public static  Datetoday()
     Returns today by setting time to 0:0:0.
final public static  shorttwoMonthShort()
     Return the ending date of this year.
final public static  shorttwoMonthShort(Date when, TimeZone tz)
     Given a date, a proper TimeZone, return the two month int.
final public static  intyearOfDate(Date when, TimeZone tz)
     Get the year of a date.



Method Detail
add
final public static Date add(Date when, TimeZone tz, int field, int amount)(Code)
Date Arithmetic function. Adds the specified (signed) amount of time to the given date, based on the calendar's rules.
Parameters:
  when - The based date.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.
Parameters:
  field - The time field.
Parameters:
  amount - The amount of date or time to be added to the field.



beginOfDate
final public static Date beginOfDate(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the beginning date of the specified date and TimeZone. If TimeZone is null, meaning use Defult TimeZone of the JVM.



beginOfMonth
final public static Date beginOfMonth()(Code)
Return the beginning date of this month.



beginOfMonth
final public static Date beginOfMonth(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone. If TimeZone is null, meaning use default TimeZone of the JVM.



beginOfYear
final public static Date beginOfYear()(Code)
Return the beginning date of this year.



beginOfYear
final public static Date beginOfYear(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone. If TimeZone is null, meaning use default TimeZone of the JVM.



dayMonthOfDate
final public static int dayMonthOfDate(Date when, TimeZone tz)(Code)
Get the day of month of a date. The first day of the month has value 1.
Parameters:
  when - The date.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.



endOfDate
final public static Date endOfDate(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the last millisecond date of the specified date and TimeZone. If TimeZone is null, meaning use Defult TimeZone of the JVM.



endOfMonth
final public static Date endOfMonth()(Code)
Return the ending date of this month.



endOfMonth
final public static Date endOfMonth(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone. If TimeZone is null, meaning use default TimeZone of the JVM.



endOfYear
final public static Date endOfYear()(Code)
Return the ending date of this year.



endOfYear
final public static Date endOfYear(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone. If TimeZone is null, meaning use default TimeZone of the JVM.



isBeginOfMonth
final public static boolean isBeginOfMonth(Date when, TimeZone tz)(Code)
Whether the given date in the specified TimeZone is the first day of that month. If TimeZone is null, meaning use default TimeZone of the JVM.



isEndOfMonth
final public static boolean isEndOfMonth(Date when, TimeZone tz)(Code)
Whether the given date in the specified TimeZone is the last day of that month. If TimeZone is null, meaning use default TimeZone of the JVM.



isRounded
final public static boolean isRounded(Date date, int precision)(Code)
Tests whether a date is rounded. It is mainly used for debugging.



localizedYearOfDate
final public static int localizedYearOfDate(Date when, Locale locale, TimeZone tz)(Code)
Get the year of a date in the specified locale.

Currenty, only Locale.ZH_TW is supported, i.e., "year - 1911" and it's may be less than 0. Otherwise, it is the same as Dates.yearOfDate .
Parameters:
  when - The date.
Parameters:
  locale - the locale; if null, the current locale is assumed.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.
See Also:   Dates.yearOfDate




merge
final public static Date merge(Date datePart, Date timePart, TimeZone tz)(Code)
merge the date part and time part of two specified dates into a date.
Parameters:
  datePart - The date part date.
Parameters:
  timePart - The time part date.
Parameters:
  tz - The time zone.



monthOfDate
final public static int monthOfDate(Date when, TimeZone tz)(Code)
Get the month of a date. The first month of the year is JANUARY which is 0.
Parameters:
  when - The date.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.



monthOfDatePlus1
final public static int monthOfDatePlus1(Date when, TimeZone tz)(Code)
Get the month of a date. The first month of the year is JANUARY which is 1.
Parameters:
  when - The date.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.



now
final public static Date now(int precision)(Code)
Returns the current time but rounding to the specified precision of milliseconds. It is useful if you want to create the current time which will be stored in the database and want to compare it with something with what you store in the database. Otherwise, that you get back the one you store might be different, because the resolution of database timestamp is usually less than one milisecond, e.g., MS SQL: 0.003 second.

If you don't cache it in the memory (remember entity beans always cache by the container), you don't need to round. If you are not sure, round it.
See Also:   Dates.round(Date,int)




now
final public static Date now()(Code)
Returns the current time without rounding.



previousDate
final public static Date previousDate(Date when)(Code)
Given a date, return the previouse date of the given date (24 hrs before).



round
final public static Date round(Date date, int precision)(Code)
Truncates date to the nearest precision milliseconds. MS SQLServer2000 with only the maximum accuracy of 1/300 seconds would not be able to store up to one millisecond accurarcy. That is, User must round the millisecond to some less precisions; or the data in that db would be inconsistence with that in memory. It is useful to store a Date object in a database. Without rounding, if you want to get it back and compare with the one in the memory. See Dates.now for details.
Parameters:
  precision - the divider of the precision(e.g. 10 for precisionof 10 milliseconds;i.e. all millisecond less than 10 would be truncated)
See Also:   Dates.now
See Also:   Dates.round(long,int)



round
final public static long round(long time, int precision)(Code)
Rounds a date represented in long to the specified precision of milliseconds.
Parameters:
  time - the date represented in long.
Parameters:
  precision - the divider of the precision(e.g. 10 for precisionof 10 milliseconds;i.e. all millisecond less than 10 would be truncated)
See Also:   Dates.now
See Also:   Dates.round(Date,int)



subtract
final public static long subtract(Date date2, TimeZone tz, int field, Date date1)(Code)
Date Arithmetic function (date2 - date1). subtract a date from another date, return the difference as the required fields. E.g. if specified Calendar.Date, the smaller range of fields is ignored and this method return the difference of days.
Parameters:
  date2 - The date2.
Parameters:
  tz - The time zone.
Parameters:
  field - The time field; e.g., Calendar.DATE, Calendar.YEAR, it's default value is Calendar.DATE
Parameters:
  date1 - The date1.



today
final public static Date today()(Code)
Returns today by setting time to 0:0:0.



twoMonthShort
final public static short twoMonthShort()(Code)
Return the ending date of this year.



twoMonthShort
final public static short twoMonthShort(Date when, TimeZone tz)(Code)
Given a date, a proper TimeZone, return the two month int. eg. 1, 3, 5, 7, 9, 11. If TimeZone is null, meaning use default TimeZone of the JVM.



yearOfDate
final public static int yearOfDate(Date when, TimeZone tz)(Code)
Get the year of a date.
Parameters:
  when - The date.
Parameters:
  tz - The time zone; if null, the current time zone is assumed.
See Also:   Dates.localizedYearOfDate



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.