Example usage for org.joda.time LocalDate getYear

List of usage examples for org.joda.time LocalDate getYear

Introduction

In this page you can find the example usage for org.joda.time LocalDate getYear.

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:com.metinkale.prayerapp.vakit.times.CalcTimes.java

License:Apache License

@Override
public String _getTime(@NonNull LocalDate date, int time) {
    List<String> times = getPrayTime().getDatePrayerTimes(date.getYear(), date.getMonthOfYear(),
            date.getDayOfMonth(), getLat(), getLng());
    times.remove(4);//w w w.ja va 2 s  . c  o  m
    return times.get(time);
}

From source file:com.metinkale.prayerapp.vakit.times.FaziletTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    String[] a = getId().split("_");

    if (a.length < 4) {
        Crashlytics.setString("FAZILET_ID", getId());
        Crashlytics.logException(new Exception("INVALID ID IN FAZILET"));
        this.delete();
        return new Builders.Any.F[0];
    }//from   ww w .  j  a  v  a  2 s  .co m
    int country = Integer.parseInt(a[1]);
    int state = Integer.parseInt(a[2]);
    int city = Integer.parseInt(a[3]);

    LocalDate ldate = LocalDate.now();
    int Y = ldate.getYear();
    int M = ldate.getMonthOfYear();

    return new Builders.Any.F[] {
            Ion.with(App.get()).load("http://www.fazilettakvimi.com/tr/namaz_vakitleri.html").setTimeout(3000)
                    .setBodyParameter("ulke_id", "" + country).setBodyParameter("sehir_id", "" + state)
                    .setBodyParameter("ilce_id", "" + city)
                    .setBodyParameter("baslangic_tarihi", Y + "-" + az(M) + "-01")
                    .setBodyParameter("bitis_tarihi", (Y + 5) + "-12-31")

    };
}

From source file:com.metinkale.prayerapp.vakit.times.IGMGTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    String path = getId().replace("nix", "-1");
    String[] a = path.split("_");
    int id = Integer.parseInt(a[1]);
    if (id <= 0 && a.length > 2)
        id = Integer.parseInt(a[2]);

    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;/*from ww  w.  j a v a2s  .  c  o  m*/
    int m = ldate.getMonthOfYear();

    final List<Builders.Any.B> queue = new ArrayList<>();
    for (int M = m; (M <= (m + 2)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        queue.add(Ion.with(App.get()).load(
                "http://www.igmg.org/wp-content/themes/igmg/include/gebetskalender_ajax.php?show_ajax_variable="
                        + id + "&show_month=" + (M - 1))
                .setTimeout(3000));
    }

    return queue.toArray(new Builders.Any.F[queue.size()]);
}

From source file:com.metinkale.prayerapp.vakit.times.MalaysiaTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;//from   ww w.  j  a  v a  2  s  .  co  m
    int m = ldate.getMonthOfYear();
    String[] split = getId().split("_");
    if (split.length < 3)
        delete();
    split[1] = URLEncoder.encode(split[1]);
    split[2] = URLEncoder.encode(split[2]);

    final List<Builders.Any.B> queue = new ArrayList<>();
    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        queue.add(Ion
                .with(App.get()).load("http://www.e-solat.gov.my/web/waktusolat.php?negeri=" + split[1]
                        + "&state=" + split[1] + "&zone=" + split[2] + "&year=" + Y + "&jenis=year&bulan=" + M)
                .setTimeout(3000));
    }

    return queue.toArray(new Builders.Any.F[queue.size()]);
}

From source file:com.metinkale.prayerapp.vakit.times.MoroccoTimes.java

License:Apache License

@NonNull
protected Builders.Any.F[] createIonBuilder() {
    LocalDate ldate = LocalDate.now();
    int rY = ldate.getYear();
    int Y = rY;/*from   w  w w . j  a v  a2  s . c o  m*/
    int m = ldate.getMonthOfYear();

    final List<Builders.Any.B> queue = new ArrayList<>();
    for (int M = m; (M <= (m + 1)) && (rY == Y); M++) {
        if (M == 13) {
            M = 1;
            Y++;
        }
        queue.add(Ion.with(App.get()).load(
                "http://www.habous.gov.ma/prieres/defaultmois.php?ville=" + getId().substring(2) + "&mois=" + M)
                .setTimeout(3000));
    }

    return queue.toArray(new Builders.Any.F[queue.size()]);
}

From source file:com.metinkale.prayerapp.vakit.times.WebTimes.java

License:Apache License

private void cleanTimes() {
    Set<String> keys = new ArraySet<>();
    keys.addAll(times.keySet());/*w  w w . j  a va 2 s .  c  o  m*/
    LocalDate date = LocalDate.now();
    int y = date.getYear();
    int m = date.getMonthOfYear();
    for (String key : keys) {
        int year = FastParser.parseInt(key.substring(0, 4));
        if (year < y)
            keys.remove(key);
        else if (year == y) {
            int month = FastParser.parseInt(key.substring(5, 7));
            if (month < m)
                keys.remove(key);
        }
    }

}

From source file:com.mycompany.ajaxandxml.ws.ReleasedAdapter.java

@Override
public String marshal(LocalDate v) throws Exception {
    return v.getYear() + "-" + v.getMonthOfYear() + "-" + v.getDayOfMonth();
}

From source file:com.ning.billing.invoice.generator.InvoiceDateUtils.java

License:Apache License

public static LocalDate calculateLastBillingCycleDateBefore(final LocalDate date,
        final LocalDate previousBillCycleDate, final int billingCycleDay, final BillingPeriod billingPeriod) {
    LocalDate proposedDate = previousBillCycleDate;

    int numberOfPeriods = 0;
    while (!proposedDate.isAfter(date)) {
        proposedDate = previousBillCycleDate.plusMonths(numberOfPeriods * billingPeriod.getNumberOfMonths());
        numberOfPeriods += 1;/*from  w w  w . ja  va  2s  . c o m*/
    }

    proposedDate = proposedDate.plusMonths(-billingPeriod.getNumberOfMonths());

    if (proposedDate.dayOfMonth().get() < billingCycleDay) {
        final int lastDayOfTheMonth = proposedDate.dayOfMonth().getMaximumValue();
        if (lastDayOfTheMonth < billingCycleDay) {
            proposedDate = new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(),
                    lastDayOfTheMonth);
        } else {
            proposedDate = new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(),
                    billingCycleDay);
        }
    }

    if (proposedDate.isBefore(previousBillCycleDate)) {
        // Make sure not to go too far in the past
        return previousBillCycleDate;
    } else {
        return proposedDate;
    }
}

From source file:com.ning.billing.invoice.generator.InvoiceDateUtils.java

License:Apache License

public static LocalDate calculateBillingCycleDateOnOrAfter(final LocalDate date,
        final int billingCycleDayLocal) {
    final int lastDayOfMonth = date.dayOfMonth().getMaximumValue();

    final LocalDate fixedDate;
    if (billingCycleDayLocal > lastDayOfMonth) {
        fixedDate = new LocalDate(date.getYear(), date.getMonthOfYear(), lastDayOfMonth, date.getChronology());
    } else {// w  w w.jav  a 2 s  .c  om
        fixedDate = new LocalDate(date.getYear(), date.getMonthOfYear(), billingCycleDayLocal,
                date.getChronology());
    }

    LocalDate proposedDate = fixedDate;
    while (proposedDate.isBefore(date)) {
        proposedDate = proposedDate.plusMonths(1);
    }
    return proposedDate;
}

From source file:com.phloc.datetime.PDTUtils.java

License:Apache License

public static boolean isSameYearAndDay(@Nonnull final LocalDate x, @Nonnull final LocalDate y) {
    return x.getYear() == y.getYear() && x.getDayOfYear() == y.getDayOfYear();
}