Example usage for org.joda.time.chrono IslamicChronology getInstance

List of usage examples for org.joda.time.chrono IslamicChronology getInstance

Introduction

In this page you can find the example usage for org.joda.time.chrono IslamicChronology getInstance.

Prototype

public static IslamicChronology getInstance() 

Source Link

Document

Gets an instance of the IslamicChronology in the default time zone.

Usage

From source file:com.jjlharrison.jollyday.util.CalendarUtil.java

License:Apache License

/**
 * Returns a set of gregorian dates within a gregorian year which equal the
 * islamic month and day. Because the islamic year is about 11 days shorter
 * than the gregorian there may be more than one occurrence of an islamic
 * date in an gregorian year. i.e.: In the gregorian year 2008 there were
 * two 1/1. They occurred on 1/10 and 12/29.
 *
 * @param gregorianYear//from w ww  . j  av  a  2  s .c om
 *            a int.
 * @param islamicMonth
 *            a int.
 * @param islamicDay
 *            a int.
 * @return List of gregorian dates for the islamic month/day.
 */
public Set<LocalDate> getIslamicHolidaysInGregorianYear(int gregorianYear, int islamicMonth, int islamicDay) {
    return getDatesFromChronologyWithinGregorianYear(islamicMonth, islamicDay, gregorianYear,
            IslamicChronology.getInstance());
}

From source file:com.metinkale.prayerapp.HicriDate.java

License:Apache License

public HicriDate(LocalDate greg) {
    // int[] key = {d, m, y};
    //int[] ret = mCache.get(key);
    //if (ret != null) return ret;
    int hfix = Prefs.getHijriFix();
    if (hfix != 0) {
        greg = greg.plusDays(hfix);/*from   ww  w .j  av  a2s .  co  m*/
    }
    int d = greg.getDayOfMonth();
    int m = greg.getMonthOfYear();
    int y = greg.getYear();

    int[] last = null;
    for (int[] date : mDates) {
        if (date[GY] < y) {
            last = date;
        } else if ((date[GY] == y) && (date[GM] < m)) {
            last = date;
        } else if ((date[GY] == y) && (date[GM] == m) && (date[GD] <= d)) {
            last = date;
        } else {
            break;
        }
    }
    if (last == null) {
        LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance())
                .toLocalDate();
        Year = date.getYear();
        Month = date.getMonthOfYear();
        Day = date.getDayOfMonth();
    } else {
        int[] h = { last[HD], last[HM], last[HY] };
        h[0] += new LocalDate(y, m, d).getDayOfYear()
                - new LocalDate(last[GY], last[GM], last[GD]).getDayOfYear();
        if ((h[0] >= 30) || (h[0] <= 0)) {
            LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance())
                    .toLocalDate();
            Year = date.getYear();
            Month = date.getMonthOfYear();
            Day = date.getDayOfMonth();
        } else {
            Year = h[HY];
            Month = h[HM];
            Day = h[HD];
        }
    }
}

From source file:org.odk.collect.android.fragments.dialogs.IslamicDatePickerDialog.java

License:Apache License

private void setUpDatePicker() {
    LocalDateTime islamicDate = DateTimeUtils.skipDaylightSavingGapIfExists(getDate()).toDateTime()
            .withChronology(IslamicChronology.getInstance()).toLocalDateTime();
    setUpDayPicker(islamicDate.getDayOfMonth(), islamicDate.dayOfMonth().getMaximumValue());
    setUpMonthPicker(islamicDate.getMonthOfYear(), monthsArray);
    setUpYearPicker(islamicDate.getYear(), MIN_SUPPORTED_YEAR, MAX_SUPPORTED_YEAR);
}

From source file:org.odk.collect.android.fragments.dialogs.IslamicDatePickerDialog.java

License:Apache License

private LocalDateTime getCurrentIslamicDate() {
    int islamicDay = getDay();
    int islamicMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int islamicYear = getYear();

    LocalDateTime islamicDate = new LocalDateTime(islamicYear, islamicMonth + 1, 1, 0, 0, 0, 0,
            IslamicChronology.getInstance());
    if (islamicDay > islamicDate.dayOfMonth().getMaximumValue()) {
        islamicDay = islamicDate.dayOfMonth().getMaximumValue();
    }//  www .j  av  a  2 s .  co m

    return new LocalDateTime(islamicYear, islamicMonth + 1, islamicDay, 0, 0, 0, 0,
            IslamicChronology.getInstance());
}