Java Doc for DateUtils.java in  » Build » ANT » org » apache » tools » ant » 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 » Build » ANT » org.apache.tools.ant.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.tools.ant.util.DateUtils

DateUtils
final public class DateUtils (Code)
Helper methods to deal with date/time formatting with a specific defined format (ISO8601) or a plurialization correct elapsed time in minutes and seconds.
since:
   Ant 1.5


Field Summary
final public static  DateFormatDATE_HEADER_FORMAT
     Format used for SMTP (and probably other) Date headers.
final public static  StringISO8601_DATETIME_PATTERN
     ISO8601-like pattern for date-time.
final public static  StringISO8601_DATE_PATTERN
     ISO8601-like pattern for date.
final public static  StringISO8601_TIME_PATTERN
     ISO8601-like pattern for time.


Method Summary
public static  Stringformat(long date, String pattern)
     Format a date/time into a specific pattern.
Parameters:
  date - the date to format expressed in milliseconds.
Parameters:
  pattern - the pattern to use to format the date.
public static  Stringformat(Date date, String pattern)
     Format a date/time into a specific pattern.
Parameters:
  date - the date to format expressed in milliseconds.
Parameters:
  pattern - the pattern to use to format the date.
public static  StringformatElapsedTime(long millis)
     Format an elapsed time into a plurialization correct string. It is limited only to report elapsed time in minutes and seconds and has the following behavior.
  • minutes are not displayed when 0.
public static  StringgetDateForHeader()
     Returns the current Date in a format suitable for a SMTP date header.
public static  intgetPhaseOfMoon(Calendar cal)
     Calculate the phase of the moon for a given date.

Code heavily influenced by hacklib.c in Nethack

The Algorithm:

 moon period = 29.53058 days ~= 30, year = 365.2422 days
 days moon phase advances on first day of year compared to preceding year
 = 365.2422 - 12*29.53058 ~= 11
 years in Metonic cycle (time until same phases fall on the same days of
 the month) = 18.6 ~= 19
 moon phase on first day of year (epact) ~= (11*(year%19) + 18) % 30
 (18 as initial condition for 1900)
 current phase in days = first day phase + days elapsed in year
 6 moons ~= 177 days
 177 ~= 8 reported phases * 22
 + 11/22 for rounding
 

Parameters:
  cal - the calander.
public static  DateparseIso8601Date(String datestr)
    
public static  DateparseIso8601DateTime(String datestr)
    
public static  DateparseIso8601DateTimeOrDate(String datestr)
     Parse a string as a date using the either the ISO8601_DATETIME or ISO8601_DATE formats.

Field Detail
DATE_HEADER_FORMAT
final public static DateFormat DATE_HEADER_FORMAT(Code)
Format used for SMTP (and probably other) Date headers.



ISO8601_DATETIME_PATTERN
final public static String ISO8601_DATETIME_PATTERN(Code)
ISO8601-like pattern for date-time. It does not support timezone. yyyy-MM-ddTHH:mm:ss



ISO8601_DATE_PATTERN
final public static String ISO8601_DATE_PATTERN(Code)
ISO8601-like pattern for date. yyyy-MM-dd



ISO8601_TIME_PATTERN
final public static String ISO8601_TIME_PATTERN(Code)
ISO8601-like pattern for time. HH:mm:ss





Method Detail
format
public static String format(long date, String pattern)(Code)
Format a date/time into a specific pattern.
Parameters:
  date - the date to format expressed in milliseconds.
Parameters:
  pattern - the pattern to use to format the date. the formatted date.



format
public static String format(Date date, String pattern)(Code)
Format a date/time into a specific pattern.
Parameters:
  date - the date to format expressed in milliseconds.
Parameters:
  pattern - the pattern to use to format the date. the formatted date.



formatElapsedTime
public static String formatElapsedTime(long millis)(Code)
Format an elapsed time into a plurialization correct string. It is limited only to report elapsed time in minutes and seconds and has the following behavior.
  • minutes are not displayed when 0. (ie: "45 seconds")
  • seconds are always displayed in plural form (ie "0 seconds" or "10 seconds") except for 1 (ie "1 second")

Parameters:
  millis - the elapsed time to report in milliseconds. the formatted text in minutes/seconds.



getDateForHeader
public static String getDateForHeader()(Code)
Returns the current Date in a format suitable for a SMTP date header. the current date.
since:
   Ant 1.5.2



getPhaseOfMoon
public static int getPhaseOfMoon(Calendar cal)(Code)
Calculate the phase of the moon for a given date.

Code heavily influenced by hacklib.c in Nethack

The Algorithm:

 moon period = 29.53058 days ~= 30, year = 365.2422 days
 days moon phase advances on first day of year compared to preceding year
 = 365.2422 - 12*29.53058 ~= 11
 years in Metonic cycle (time until same phases fall on the same days of
 the month) = 18.6 ~= 19
 moon phase on first day of year (epact) ~= (11*(year%19) + 18) % 30
 (18 as initial condition for 1900)
 current phase in days = first day phase + days elapsed in year
 6 moons ~= 177 days
 177 ~= 8 reported phases * 22
 + 11/22 for rounding
 

Parameters:
  cal - the calander. The phase of the moon as a number between 0 and 7 with0 meaning new moon and 4 meaning full moon.
since:
   1.2, Ant 1.5



parseIso8601Date
public static Date parseIso8601Date(String datestr) throws ParseException(Code)
Parse a string as a date using the ISO8601_DATE format which is yyyy-MM-dd
Parameters:
  datestr - string to be parsed a java.util.Date object as parsed by the format.
exception:
  ParseException - if the supplied string cannot be parsed bythis pattern.
since:
   Ant 1.6



parseIso8601DateTime
public static Date parseIso8601DateTime(String datestr) throws ParseException(Code)
Parse a string as a datetime using the ISO8601_DATETIME format which is yyyy-MM-dd'T'HH:mm:ss
Parameters:
  datestr - string to be parsed a java.util.Date object as parsed by the format.
exception:
  ParseException - if the supplied string cannot be parsed bythis pattern.
since:
   Ant 1.6



parseIso8601DateTimeOrDate
public static Date parseIso8601DateTimeOrDate(String datestr) throws ParseException(Code)
Parse a string as a date using the either the ISO8601_DATETIME or ISO8601_DATE formats.
Parameters:
  datestr - string to be parsed a java.util.Date object as parsed by the formats.
exception:
  ParseException - if the supplied string cannot be parsed byeither of these patterns.
since:
   Ant 1.6



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.