Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse BIRT Report Developer Guide
Previous Page Home Next Page

Previous Next

Class BirtDuration

The BirtDuration class provides functions to get parts of time periods, or durations, used in XML documents. The durations are specified in the following form:

P nYnMnDTnHnMnS

where:

n
n Y indicates the number of years
n
n M indicates the number of months
n
n D indicates the number of days
n
n H indicates the number of hours
n
n M indicates the number of minutes
n
n S indicates the number of seconds

For example, the following value indicates a duration of 2 years, 3 months, and 5 days:

The following value indicates a duration of 10 hours:

The BirtDuration class is static. The application cannot create instances of the class.

BirtDuration.day

This function returns the days value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the days value.

Returns

A number that represents the days value of the specified duration.

Examples

The following examples show the day values returned for specific durations:

BirtDuration.day( "P5Y2M" ) // returns 0

BirtDuration.hour

This function returns the hours value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the hours value.

Returns

A number that represents the hours value of the specified duration.

Examples

The following examples show the hour values returned for specific durations:

BirtDuration.isLongerThan

This function tests if a duration is longer than another duration. Sometimes the order relationship between certain durations cannot be determined, for example, one month (P1M) and 30 days (P30D), or one year (P1Y) and 365 days (P365D). In cases such as these, the function returns false.

Syntax

Parameters

lexicalDuration1

The first duration to use in the comparison.

lexicalDuration2

The second duration to use in the comparison.

Returns

True if the first duration is longer than the second duration; returns false otherwise.

Examples

The following expressions compare the lengths of specific durations:

BirtDuration.isShorterThan

This function tests if a duration is shorter than another duration. Sometimes the order relationship between certain durations cannot be determined, for example, one month (P1M) and 30 days (P30D), or one year (P1Y) and 365 days (P365D). In cases such as these, the function returns false.

Syntax

Parameters

lexicalDuration1

The first duration to use in the comparison.

lexicalDuration2

The second duration to use in the comparison.

Returns

True if the first duration is shorter than the second duration; returns false otherwise.

Examples

The following expressions compare the lengths of specific durations:

BirtDuration.minute

This function returns the minutes value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the minutes value.

Returns

A number that represents the minutes value of the specified duration.

Examples

The following examples show the minutes values returned for specific durations:

BirtDuration.month

This function returns the months value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the months value.

Returns

A number that represents the months value of the specified duration.

Examples

The following examples show the month values returned for specific durations:

BirtDuration.second

This function returns the seconds value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the seconds value.

Returns

A number that represents the seconds value of the specified duration.

Examples

The following examples show the seconds values returned for specific durations:

BirtDuration.timeInMills

This function returns the number of milliseconds in a given duration, from a specified start date. The number of milliseconds in a duration can change depending on the start date. For example, a duration of one month can be 28, 29, 30, or 31 days, depending on the start date. If the start date is January 1, the function calculates the milliseconds between January 1 and February 1 (excluding February 1), which equals 2678400000 milliseconds or 31 days. If the start date is February 1, 2009 (a leap year), the function calculates the milliseconds between February 1 and March 1, which equals 2505600000 milliseconds or 29 days.

Syntax

Parameters

lexicalDuration

A duration whose length in milliseconds to get.

startDate

A date object that represents the start date.

Returns

The number of milliseconds in the specified duration.

Examples

The following examples show the number of milliseconds returned for specific durations and start dates:

BirtDuration.timeInMills( "P1Y3M10D" , "2009-01-01" ) // returns 40172400000
BirtDuration.timeInMills( "P1Y3M10D" , "2008-01-01" ) // returns 40258800000

BirtDuration.year

This function returns the year value of a given duration.

Syntax

Parameter

lexicalDuration

A duration from which to get the year value.

Returns

A number that represents the year value of the specified duration.

Examples

The following examples show the year values returned for specific durations:


(c) Copyright Actuate Corporation 2009

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire