com.ghasemkiani.util
Class SimplePersianCalendar

java.lang.Object
  extended byjava.util.Calendar
      extended byjava.util.GregorianCalendar
          extended bycom.ghasemkiani.util.SimplePersianCalendar
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, PersianCalendarConstants, java.io.Serializable

public class SimplePersianCalendar
extends java.util.GregorianCalendar
implements PersianCalendarConstants

This class is a subclass of java.util.GregorianCalendar, with the added functionality that it can set/get date in the Persian calendar system. The algorithms for conversion between Persian and Gregorian calendar systems are placed in PersianCalendarHelper class.

Version:
2.1
Author:
Ghasem Kiani
See Also:
Serialized Form

Field Summary
static java.lang.String[] persianMonths
          Persian month names.
static java.lang.String[] persianWeekDays
          Persian week day names.
 
Fields inherited from class java.util.GregorianCalendar
AD, BC
 
Fields inherited from class java.util.Calendar
AM, AM_PM, APRIL, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, FRIDAY, HOUR, HOUR_OF_DAY, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
 
Fields inherited from interface com.ghasemkiani.util.PersianCalendarConstants
ABAN, AZAR, BAHMAN, DEY, ESFAND, FARVARDIN, KHORDAD, MEHR, MORDAD, ORDIBEHESHT, SHAHRIVAR, TIR
 
Constructor Summary
SimplePersianCalendar()
           
 
Method Summary
 DateFields getDateFields()
          Retrieves the date of this calendar object as the Persian date fields
 long getJulianDay()
          Get the Julian day corresponding to the date of this calendar.
 java.lang.String getPersianMonthName()
          Gives the name of the current Persian month for this calendar's date.
static java.lang.String getPersianMonthName(int month)
          Gives the name of the specified Persian month.
 java.lang.String getPersianWeekDayName()
          Gives the Persian name of the current day of the week for this calendar's date.
static java.lang.String getPersianWeekDayName(int weekDay)
          Gives the Persian name of the specified day of week.
 void setDateFields(DateFields dateFields)
          Sets the date of this calendar object to the specified Persian date fields
 void setDateFields(int year, int month, int day)
          Sets the date of this calendar object to the specified Persian date (year, month, and day fields)
 void setJulianDay(long julianDay)
          Set the date of this calendar to the specified Julian day.
 
Methods inherited from class java.util.GregorianCalendar
add, clone, equals, getActualMaximum, getActualMinimum, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, hashCode, isLeapYear, roll, roll, setGregorianChange, setTimeZone
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

persianMonths

public static final java.lang.String[] persianMonths
Persian month names.

Since:
1.1

persianWeekDays

public static final java.lang.String[] persianWeekDays
Persian week day names.

Since:
1.1
Constructor Detail

SimplePersianCalendar

public SimplePersianCalendar()
Method Detail

getJulianDay

public long getJulianDay()
Get the Julian day corresponding to the date of this calendar.

Returns:
the Julian day corresponding to the date of this calendar.
Since:
2.0

setJulianDay

public void setJulianDay(long julianDay)
Set the date of this calendar to the specified Julian day.

Parameters:
julianDay - the desired Julian day to be set as the date of this calendar.
Since:
2.0

setDateFields

public void setDateFields(int year,
                          int month,
                          int day)
Sets the date of this calendar object to the specified Persian date (year, month, and day fields)

Parameters:
year - the Persian year.
month - the Persian month (zero-based).
day - the Persian day of month.
Since:
1.0

setDateFields

public void setDateFields(DateFields dateFields)
Sets the date of this calendar object to the specified Persian date fields

Parameters:
dateFields - the Persian date fields.
Since:
1.0

getDateFields

public DateFields getDateFields()
Retrieves the date of this calendar object as the Persian date fields

Returns:
the date of this calendar as Persian date fields.
Since:
1.0

getPersianMonthName

public static java.lang.String getPersianMonthName(int month)
Gives the name of the specified Persian month.

Parameters:
month - the Persian month (zero-based).
Returns:
the name of the specified Persian month in Persian.
Since:
1.1

getPersianMonthName

public java.lang.String getPersianMonthName()
Gives the name of the current Persian month for this calendar's date.

Returns:
the name of the current Persian month for this calendar's date in Persian.
Since:
1.3

getPersianWeekDayName

public static java.lang.String getPersianWeekDayName(int weekDay)
Gives the Persian name of the specified day of week.

Parameters:
weekDay - the day of week (use symbolic constants in the java.util.Calendar class).
Returns:
the name of the specified day of week in Persian.
Since:
1.1

getPersianWeekDayName

public java.lang.String getPersianWeekDayName()
Gives the Persian name of the current day of the week for this calendar's date.

Returns:
the name of the current day of week for this calendar's date in Persian.
Since:
1.3