>>
MonitorIt
>>
Log In
>>
monitorit
>>
monitorit
>>
JbbDate
Table of Contents
Description
The JbbDate class allows you to perform powerful and extensive date and time manipulations as shown in the
following section
and in the
JavaDoc documentation of the class.
The key concept is that the JbbDate is instantiated with a given date and locale.
Once the JbbDate instance has been set up, you can then directy call any of its methods.
Please note that there are actually two types of methods:
- The getXxx() methods allow you to directly obtain a java.util.Date instance without modifying the internal reference date.
For instance, the getBeginningNextBusinessDay() returns a java.util.Date instance corresponding to the beginning (i.e. 00:00:00) of the first business day that follows the internal reference date.
// new instance initialized with the current date and time and the default locale
JbbDate date1 = JbbFactory.newJbbDate();
Date myDate1= date1.getBeginningNextBusinessDay();
// new instance initialized with the current date and time and the French locale
JbbDate date2 = JbbFactory.newJbbDate(Locale.FRANCE);
Date myDate2= date2.getBeginningNextBusinessDay();
-
The setXxx() methods allow you to directly modify the internal reference date.
For instance, you would use the following code to obtain the date corresponding to the first day of the week in a US locale (the first day of a week in the USA is Sunday but did you know that the first day of the week in Hungary is Monday?) at 21:15:50
JbbDate date1 = JbbFactory.newJbbDate(Locale.US);
System.out.println("Input: " + date1.formatDateTimeFull());
date1.setDateBeginningOfNextWeek();
date1.setDateSameDay(21,15,50,000);
System.out.println("Output: " + date1.formatDateTimeFull());
The corresponding execution results are:
Input: Monday, July 31, 2000 10:59:34 PM EDT
Result: Sunday, August 6, 2000 9:15:50 PM EDT
Once the manipulations have been applied, you can then obtain the corresponding date as a java.util.Date instance or as the number of milliseconds since January, 1970:
Please feel free to contact us to provide your feedback/questions/comments/suggestions as well. We've spent a large amount of time to design and develop the corresponding software and all its associated documentation, we would love to hear from you!
Sample Code
To obtain the date corresponding to the Wednesday 8:30 AM of he week 45 in the year 2007 (in German locale):
JbbDate date1 = JbbFactory.newJbbDate(Locale.US);
date1.setYear(2007);
date1.setNthDayOfWeek(45,Calendar.WEDNESDAY);
date1.setSameDayWithDifferentTime(8,30,0,0);
System.out.println(date1.formatDateTimeFull());
Wednesday, November 7, 2007 8:30:00 AM EST
Our sample code exist of the JUnit test suite we run each time a build is executed.
Download the JUnit test suite for JbbDate and use
it as a reference for your coding adventures.
Prerequisites
The JbbDate class does not have any prerequisite other than the JRE version 5 or above.