public class PersianCalendar extends com.ibm.icu.util.Calendar implements PersianCalendarConstants
This is an arithmetic implementation of the Persian Calendar (also known as the Iranian or Jalali Calendar) based on the calendar framework of ICU4J (IBM's International Components for Unicode for Java), version 3.2.
ICU4J is copyright International Business Machines Corporation (IBM).
Please see the file icu4j_3_2_license.html included with
this software package for information about ICU4J license.
An astronomical version of the Persian Calendar may be implemented in a future release.
Usage Example
The following code snippet shows how to use the class:
PersianCalendar
import java.util.Date;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.text.DateFormat;
import com.ghasemkiani.util.icu.PersianCalendar;
// ...
PersianCalendar pc = new PersianCalendar(TimeZone.getTimeZone("Asia/Tehran"));
DateFormat df = pc.getDateTimeFormat(DateFormat.FULL, DateFormat.DEFAULT, new ULocale("fa", "IR", ""));
String result = df.format(new Date());
// ...
Some possible results are shown below:
| Locale | Formatted String |
|---|---|
| فارسی | جمعه، ۷ اسفند ۱۳۸۳ ۱۲:۰۰:۳۹ |
| فارسی (افغانستان) | جمعه، ۷ حوت ۱۳۸۳ ۱۲:۰۰:۳۹ |
| العربية | الجمعة, ٧ إسفند, ١٣٨٣ ١٢:٠٠:٣٩ م |
| English | Friday, Esfand 7, 1383 12:00:39 PM |
| Français | vendredi 7 Esfand 1383 12:00:39 |
| Deutsch | Freitag, 7. Esfand 1383 12:00:39 |
| Русский | 7 Эсфанд 1383 г. 12:00:39 |
| Türkçe | 07 Isfend 1383 Cuma 12:00:39 |
| Esperanto | vendredo, 7-a de esfando 1383 12:00:39 |
| Modifier and Type | Field and Description |
|---|---|
static int |
AH
After Hijra Era.
|
static int |
BH
Before Hijra Era.
|
AM, AM_PM, APRIL, AUGUST, BASE_FIELD_COUNT, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DOW_LOCAL, DST_OFFSET, EPOCH_JULIAN_DAY, ERA, EXTENDED_YEAR, FEBRUARY, FRIDAY, GREATEST_MINIMUM, HOUR, HOUR_OF_DAY, INTERNALLY_SET, IS_LEAP_MONTH, JAN_1_1_JULIAN_DAY, JANUARY, JULIAN_DAY, JULY, JUNE, LEAST_MAXIMUM, MARCH, MAX_DATE, MAX_FIELD_COUNT, MAX_JULIAN, MAX_MILLIS, MAXIMUM, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MIN_DATE, MIN_JULIAN, MIN_MILLIS, MINIMUM, MINIMUM_USER_STAMP, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, PM, RESOLVE_REMAP, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, UNSET, WALLTIME_FIRST, WALLTIME_LAST, WALLTIME_NEXT_VALID, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET| Constructor and Description |
|---|
PersianCalendar()
Constructs a Persian calendar with the default time zone and locale.
|
PersianCalendar(Date date)
Constructs a Persian calendar with the default time zone and locale
and sets its time to the specified date-time.
|
PersianCalendar(int year,
int month,
int date)
Constructs a Persian calendar with the default time zone and locale
and sets its time to the specified date.
|
PersianCalendar(int year,
int month,
int date,
int hour,
int minute,
int second)
Constructs a Persian calendar with the default time zone and locale
and sets its time to the specified time.
|
PersianCalendar(Locale aLocale)
Constructs a Persian calendar with the default time zone and the specified locale.
|
PersianCalendar(com.ibm.icu.util.TimeZone zone)
Constructs a Persian calendar with the specified time zone and the default locale.
|
PersianCalendar(com.ibm.icu.util.TimeZone zone,
Locale aLocale)
Constructs a Persian calendar with the specified time zone and locale.
|
PersianCalendar(com.ibm.icu.util.TimeZone zone,
com.ibm.icu.util.ULocale locale)
Constructs a Persian calendar with the specified time zone and locale.
|
PersianCalendar(com.ibm.icu.util.ULocale locale)
Constructs a Persian calendar with the default time zone and the specified locale.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int field,
int amount)
Adds the specified amount to the specified field of this calendar.
|
String |
getType()
Type of this calendar.
|
protected void |
handleComputeFields(int julianDay) |
protected int |
handleComputeMonthStart(int extendedYear,
int month,
boolean useMonth) |
protected com.ibm.icu.text.DateFormat |
handleGetDateFormat(String pattern,
com.ibm.icu.util.ULocale locale) |
protected int |
handleGetExtendedYear() |
protected int |
handleGetLimit(int field,
int limitType) |
protected int |
handleGetMonthLength(int extendedYear,
int month) |
protected int |
handleGetYearLength(int extendedYear) |
after, before, clear, clear, clone, compareTo, complete, computeFields, computeGregorianFields, computeGregorianMonthStart, computeJulianDay, computeMillisInDay, computeTime, computeZoneOffset, equals, fieldDifference, fieldName, floorDivide, floorDivide, floorDivide, floorDivide, get, getActualMaximum, getActualMinimum, getAvailableLocales, getAvailableULocales, getDateTimeFormat, getDateTimeFormat, getDateTimePattern, getDayOfWeekType, getDefaultDayInMonth, getDefaultMonthInYear, getDisplayName, getDisplayName, getFieldCount, getFieldResolutionTable, getFirstDayOfWeek, getGreatestMinimum, getGregorianDayOfMonth, getGregorianDayOfYear, getGregorianMonth, getGregorianYear, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getKeywordValuesForLocale, getLeastMaximum, getLimit, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getRepeatedWallTimeOption, getSkippedWallTimeOption, getStamp, getTime, getTimeInMillis, getTimeZone, getWeekendTransition, gregorianMonthLength, gregorianPreviousMonthLength, handleComputeJulianDay, handleCreateFields, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, hashCode, internalGet, internalGet, internalGetTimeInMillis, internalSet, isEquivalentTo, isGregorianLeapYear, isLenient, isSet, isWeekend, isWeekend, julianDayToDayOfWeek, julianDayToMillis, millisToJulianDay, newerField, newestStamp, pinField, prepareGetActual, resolveFields, roll, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setRepeatedWallTimeOption, setSkippedWallTimeOption, setTime, setTimeInMillis, setTimeZone, toString, validateField, validateField, validateFields, weekNumber, weekNumberpublic static final int BH
public static final int AH
public PersianCalendar()
public PersianCalendar(com.ibm.icu.util.TimeZone zone)
zone - the desired timezone.public PersianCalendar(Locale aLocale)
aLocale - the desired locale.public PersianCalendar(com.ibm.icu.util.ULocale locale)
locale - the desired locale.public PersianCalendar(com.ibm.icu.util.TimeZone zone,
Locale aLocale)
zone - the desired timezone.aLocale - the desired locale.public PersianCalendar(com.ibm.icu.util.TimeZone zone,
com.ibm.icu.util.ULocale locale)
zone - the desired timezone.locale - the desired locale.public PersianCalendar(Date date)
date - the date of this calendar object.public PersianCalendar(int year,
int month,
int date)
year - the Persian year.month - the Persian month (zero-based).date - the Persian day of month.public PersianCalendar(int year,
int month,
int date,
int hour,
int minute,
int second)
year - the Persian year.month - the Persian month (zero-based).date - the Persian day of month.hour - the hours part of time.minute - the minutes part of time.second - the seconds part of time.protected int handleGetLimit(int field,
int limitType)
handleGetLimit in class com.ibm.icu.util.Calendarprotected int handleGetMonthLength(int extendedYear,
int month)
handleGetMonthLength in class com.ibm.icu.util.Calendarprotected int handleGetYearLength(int extendedYear)
handleGetYearLength in class com.ibm.icu.util.Calendarprotected int handleComputeMonthStart(int extendedYear,
int month,
boolean useMonth)
handleComputeMonthStart in class com.ibm.icu.util.Calendarprotected int handleGetExtendedYear()
handleGetExtendedYear in class com.ibm.icu.util.Calendarprotected void handleComputeFields(int julianDay)
handleComputeFields in class com.ibm.icu.util.Calendarprotected com.ibm.icu.text.DateFormat handleGetDateFormat(String pattern, com.ibm.icu.util.ULocale locale)
handleGetDateFormat in class com.ibm.icu.util.Calendarpublic void add(int field,
int amount)
add in class com.ibm.icu.util.Calendarfield - the field index.amount - the amount to add.public String getType()
Type of this calendar.
Type is used for loading resources. Since there is no calendar data for
this type ("persian"), the CalendarData will use the fallback type
("gregorian"). This is fine, just the month names and era names must
be changed. This is taken care of by PersianDateFormatSymbols,
which uses a java resource bundle in its turn.
getType in class com.ibm.icu.util.CalendarCopyright © 2015. All Rights Reserved.