org.mycore.common
Class MCRCalendar

java.lang.Object
  extended by org.mycore.common.MCRCalendar

public class MCRCalendar
extends Object

This class implements all methods for handling calendars in MyCoRe objects and data models. It use the GPL licensed ICU library of IBM.

Version:
$Revision: 1.8 $ $Date: 2008/05/28 13:43:31 $
Author:
Jens Kupferschmidt, Thomas Junge
See Also:
http://icu.sourceforge.net/

Field Summary
static String[] CALENDARS_ICU
          all available calendars of ICU
static String[] CALENDARS_INPUT
          convert following calendars from input to gregorian
(package private) static Logger LOGGER
          Logger
static int MAX_JULIAN_DAY_NUMBER
          Maximum Julian Day number is 3182057 = 31.12.3999
static int MIN_JULIAN_DAY_NUMBER
          Minimum Julian Day number is 0 = 01.01.4713 BC
static String TAG_ARMENIAN
           
static String TAG_BUDDHIST
          Tag for calendars
static String TAG_CHINESE
           
static String TAG_COPTIC
           
static String TAG_EGYPTIAN
           
static String TAG_ETHIOPIC
           
static String TAG_GREGORIAN
           
static String TAG_HEBREW
           
static String TAG_ISLAMIC
           
static String TAG_ISLAMIC_CIVIL
           
static String TAG_JAPANESE
           
static String TAG_JULIAN
           
static String TAG_PERSIC
           
 
Constructor Summary
MCRCalendar()
           
 
Method Summary
static String getDateToFormattedString(com.ibm.icu.util.Calendar date)
          This method returns the date as string in format 'dd.MM.yyyy G'.
static String getDateToFormattedString(com.ibm.icu.util.Calendar date, String format)
          This method returns the date as string.
static com.ibm.icu.util.GregorianCalendar getGregorianHistoryDate(String datestr, boolean last)
          This method convert a ancient date to a GregorianCalendar value.
static com.ibm.icu.util.GregorianCalendar getGregorianHistoryDate(String datestr, boolean last, String calstr)
          This method convert a ancient date to a GregorianCalendar value.
static int getJulianDayNumber(com.ibm.icu.util.Calendar date)
          This method return the Julian Day number for a given Calendar instance.
static boolean testHistoryDate(String datestr, boolean last, String calstr)
          This method test a ancient date string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

static Logger LOGGER
Logger


TAG_BUDDHIST

public static String TAG_BUDDHIST
Tag for calendars


TAG_CHINESE

public static String TAG_CHINESE

TAG_COPTIC

public static String TAG_COPTIC

TAG_ETHIOPIC

public static String TAG_ETHIOPIC

TAG_GREGORIAN

public static String TAG_GREGORIAN

TAG_HEBREW

public static String TAG_HEBREW

TAG_ISLAMIC

public static String TAG_ISLAMIC

TAG_ISLAMIC_CIVIL

public static String TAG_ISLAMIC_CIVIL

TAG_JAPANESE

public static String TAG_JAPANESE

TAG_JULIAN

public static String TAG_JULIAN

TAG_PERSIC

public static String TAG_PERSIC

TAG_ARMENIAN

public static String TAG_ARMENIAN

TAG_EGYPTIAN

public static String TAG_EGYPTIAN

MIN_JULIAN_DAY_NUMBER

public static int MIN_JULIAN_DAY_NUMBER
Minimum Julian Day number is 0 = 01.01.4713 BC


MAX_JULIAN_DAY_NUMBER

public static int MAX_JULIAN_DAY_NUMBER
Maximum Julian Day number is 3182057 = 31.12.3999


CALENDARS_ICU

public static String[] CALENDARS_ICU
all available calendars of ICU


CALENDARS_INPUT

public static String[] CALENDARS_INPUT
convert following calendars from input to gregorian

Constructor Detail

MCRCalendar

public MCRCalendar()
Method Detail

getGregorianHistoryDate

public static final com.ibm.icu.util.GregorianCalendar getGregorianHistoryDate(String datestr,
                                                                               boolean last)
                                                                        throws MCRException
This method convert a ancient date to a GregorianCalendar value. For syntax of the string see javadocs of calendar methods.

Parameters:
datestr - the date as string.
last - the value is true if the date should be filled with the highest value of month or day like 12 or 31 else it fill the date with the lowest value 1 for month and day.
Returns:
the GregorianCalendar date value or null if an error was occurred.
Throws:
a - MCRException if parsing has an error
MCRException

getGregorianHistoryDate

public static final com.ibm.icu.util.GregorianCalendar getGregorianHistoryDate(String datestr,
                                                                               boolean last,
                                                                               String calstr)
                                                                        throws MCRException
This method convert a ancient date to a GregorianCalendar value. For syntax of the string see javadocs of calendar methods.

Parameters:
datestr - the date as string.
last - the value is true if the date should be filled with the highest value of month or day like 12 or 31 else it fill the date with the lowest value 1 for month and day.
calstr - the calendar as String, kind of the calendar name ('gregorian', 'julian', 'islamic', 'coptic', 'ethiopic', 'buddhist', 'japanese', 'persic', 'armenian', 'egyptian')
Returns:
the GregorianCalendar date value or null if an error was occurred.
Throws:
a - MCRException if parsing has an error
MCRException

testHistoryDate

public static final boolean testHistoryDate(String datestr,
                                            boolean last,
                                            String calstr)
This method test a ancient date string. For syntax of the string see javadocs of calendar methods.

Parameters:
datestr - the date as string.
last - the value is true if the date should be filled with the highest value of month or day like 12 or 31 else it fill the date with the lowest value 1 for month and day.
calstr - the calendar as String, kind of the calendar ('gregorian', 'julian', 'islamic', 'coptic', 'ethiopic', 'buddhist', 'japanese', 'persic', ''armenian, 'egyptian')
Returns:
the GregorianCalendar date value or null if an error was occurred.

getJulianDayNumber

public static final int getJulianDayNumber(com.ibm.icu.util.Calendar date)
This method return the Julian Day number for a given Calendar instance.

Parameters:
date - an instance of a Calendar
Returns:
the Julian Day number

getDateToFormattedString

public static final String getDateToFormattedString(com.ibm.icu.util.Calendar date)
This method returns the date as string in format 'dd.MM.yyyy G'.

Parameters:
date - the GregorianCalendar date
Returns:
the date string

getDateToFormattedString

public static final String getDateToFormattedString(com.ibm.icu.util.Calendar date,
                                                    String format)
This method returns the date as string.

Parameters:
date - the GregorianCalendar date
format - the format of the date as String
Returns:
the date string in the format. If the format is wrong dd.MM.yyyy G is set. If the date is wrong an empty string will be returned.