MDateSelector

mseries.utils
Class SafeCalendarUtils

java.lang.Object
  extended by mseries.utils.SafeCalendarUtils

public class SafeCalendarUtils
extends Object

Class created to "work-around" an apparent bug with sun.util.BuddhistCalendar (hardcoded to be returned by Calendar.getInstance() calls for the Thai locale (language)). The bug causes the Calendar date to become incorrect (e.g. 1998 + 5 years becomes 1460) whenever a .add(...) call forces a year change.

Version:
1.0
Author:
S. Ruman
See Also:
Calendar

Constructor Summary
SafeCalendarUtils()
           
 
Method Summary
static void doSafeAddition(Calendar cal, int field, int amount)
          Creates a temporary GregorianCalendar, sets its time, uses it for the addition, and then sets the modified time to the passed in Calendar.
static String squeeze(String input)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeCalendarUtils

public SafeCalendarUtils()
Method Detail

squeeze

public static String squeeze(String input)

doSafeAddition

public static final void doSafeAddition(Calendar cal,
                                        int field,
                                        int amount)
Creates a temporary GregorianCalendar, sets its time, uses it for the addition, and then sets the modified time to the passed in Calendar. Note: This convenience performs a .add(...) call (as opposed to a .roll(...) call) on the Calendar.

Parameters:
cal - The calendar to be modified by adding the amount of field to it
field - A constant from the Calendar class (DAY, MONTH, etc.)
amount - The amount of field to add to the calendar.

MDateSelector

Copyright © 2001-2007 M Newstead. All Rights Reserved.