Java Doc for DurationFormatUtils.java in  » Library » Apache-common-lang » org » apache » commons » lang » time » 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 » Library » Apache common lang » org.apache.commons.lang.time 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.lang.time.DurationFormatUtils

DurationFormatUtils
public class DurationFormatUtils (Code)

Duration formatting utilities and constants. The following table describes the tokens used in the pattern language for formatting.

characterduration element
yyears
Mmonths
ddays
Hhours
mminutes
sseconds
Smilliseconds

author:
   Apache Ant - DateUtils
author:
   Stephane Bailliez
author:
   Stefan Bodewig
author:
   Stephen Colebourne
author:
   Gary Gregory
since:
   2.1
version:
   $Id: DurationFormatUtils.java 491654 2007-01-01 22:04:34Z ggregory $

Inner Class :static class Token

Field Summary
final static  ObjectH
    
final public static  StringISO_EXTENDED_FORMAT_PATTERN
    
final static  ObjectM
    
final static  ObjectS
    
final static  Objectd
    
final static  Objectm
    
final static  Objects
    
final static  Objecty
    

Constructor Summary
public  DurationFormatUtils()
    

Method Summary
static  Stringformat(Token[] tokens, int years, int months, int days, int hours, int minutes, int seconds, int milliseconds, boolean padWithZeros)
    
public static  StringformatDuration(long durationMillis, String format)
    

Formats the time gap as a string, using the specified format, and padding with zeros and using the default timezone.

This method formats durations using the days and lower fields of the format pattern.

public static  StringformatDuration(long durationMillis, String format, boolean padWithZeros)
    

Formats the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.

This method formats durations using the days and lower fields of the format pattern.

public static  StringformatDurationHMS(long durationMillis)
    
public static  StringformatDurationISO(long durationMillis)
    
public static  StringformatDurationWords(long durationMillis, boolean suppressLeadingZeroElements, boolean suppressTrailingZeroElements)
    

Formats an elapsed time into a plurialization correct string.

This method formats durations using the days and lower fields of the format pattern.

public static  StringformatPeriod(long startMillis, long endMillis, String format)
    

Formats the time gap as a string, using the specified format.

public static  StringformatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone)
    

Formats the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.

public static  StringformatPeriodISO(long startMillis, long endMillis)
    
static  Token[]lexx(String format)
    

Field Detail
H
final static Object H(Code)



ISO_EXTENDED_FORMAT_PATTERN
final public static String ISO_EXTENDED_FORMAT_PATTERN(Code)

Pattern used with FastDateFormat and SimpleDateFormat for the ISO8601 period format used in durations.


See Also:   org.apache.commons.lang.time.FastDateFormat
See Also:   java.text.SimpleDateFormat



M
final static Object M(Code)



S
final static Object S(Code)



d
final static Object d(Code)



m
final static Object m(Code)



s
final static Object s(Code)



y
final static Object y(Code)




Constructor Detail
DurationFormatUtils
public DurationFormatUtils()(Code)

DurationFormatUtils instances should NOT be constructed in standard programming.

This constructor is public to permit tools that require a JavaBean instance to operate.





Method Detail
format
static String format(Token[] tokens, int years, int months, int days, int hours, int minutes, int seconds, int milliseconds, boolean padWithZeros)(Code)

The internal method to do the formatting.


Parameters:
  tokens - the tokens
Parameters:
  years - the number of years
Parameters:
  months - the number of months
Parameters:
  days - the number of days
Parameters:
  hours - the number of hours
Parameters:
  minutes - the number of minutes
Parameters:
  seconds - the number of seconds
Parameters:
  milliseconds - the number of millis
Parameters:
  padWithZeros - whether to pad the formatted string



formatDuration
public static String formatDuration(long durationMillis, String format)(Code)

Formats the time gap as a string, using the specified format, and padding with zeros and using the default timezone.

This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.


Parameters:
  durationMillis - the duration to format
Parameters:
  format - the way in which to format the duration the time as a String



formatDuration
public static String formatDuration(long durationMillis, String format, boolean padWithZeros)(Code)

Formats the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.

This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.


Parameters:
  durationMillis - the duration to format
Parameters:
  format - the way in which to format the duration
Parameters:
  padWithZeros - whether to pad the left hand side of numbers with 0's the time as a String



formatDurationHMS
public static String formatDurationHMS(long durationMillis)(Code)

Formats the time gap as a string.

The format used is ISO8601-like: H:m:s.S.


Parameters:
  durationMillis - the duration to format the time as a String



formatDurationISO
public static String formatDurationISO(long durationMillis)(Code)

Formats the time gap as a string.

The format used is the ISO8601 period format.

This method formats durations using the days and lower fields of the ISO format pattern, such as P7D6TH5M4.321S.


Parameters:
  durationMillis - the duration to format the time as a String



formatDurationWords
public static String formatDurationWords(long durationMillis, boolean suppressLeadingZeroElements, boolean suppressTrailingZeroElements)(Code)

Formats an elapsed time into a plurialization correct string.

This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.


Parameters:
  durationMillis - the elapsed time to report in milliseconds
Parameters:
  suppressLeadingZeroElements - suppresses leading 0 elements
Parameters:
  suppressTrailingZeroElements - suppresses trailing 0 elements the formatted text in days/hours/minutes/seconds



formatPeriod
public static String formatPeriod(long startMillis, long endMillis, String format)(Code)

Formats the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional.
Parameters:
  startMillis - the start of the duration
Parameters:
  endMillis - the end of the duration
Parameters:
  format - the way in which to format the duration the time as a String




formatPeriod
public static String formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone)(Code)

Formats the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.

When calculating the difference between months/days, it chooses to calculate months first. So when working out the number of months and days between January 15th and March 10th, it choose 1 month and 23 days gained by choosing January->February = 1 month and then calculating days forwards, and not the 1 month and 26 days gained by choosing March -> February = 1 month and then calculating days backwards.

For more control, the Joda-Time library is recommended.


Parameters:
  startMillis - the start of the duration
Parameters:
  endMillis - the end of the duration
Parameters:
  format - the way in which to format the duration
Parameters:
  padWithZeros - whether to pad the left hand side of numbers with 0's
Parameters:
  timezone - the millis are defined in the time as a String



formatPeriodISO
public static String formatPeriodISO(long startMillis, long endMillis)(Code)

Formats the time gap as a string.

The format used is the ISO8601 period format.


Parameters:
  startMillis - the start of the duration to format
Parameters:
  endMillis - the end of the duration to format the time as a String



lexx
static Token[] lexx(String format)(Code)
Parses a classic date format string into Tokens
Parameters:
  format - to parse Token[] of tokens



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.