Example usage for org.joda.time LocalDate withDayOfYear

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

Introduction

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

Prototype

public LocalDate withDayOfYear(int dayOfYear) 

Source Link

Document

Returns a copy of this date with the day of year field updated.

Usage

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

License:Apache License

protected boolean parseResult(String r) {
    LocalDate date = LocalDate.now();
    List<Day> result = new Gson().fromJson(r, new TypeToken<List<Day>>() {
    }.getType());//  ww  w .j  ava2s  . c  o  m
    for (Day d : result) {
        date = date.withDayOfYear(d.Day);
        setTimes(date, new String[] { d.Fajr, d.Tulu, d.Zuhr, d.Asr, d.Maghrib, d.Isha });
    }
    return result.size() > 25;
}

From source file:net.objectlab.kit.datecalc.joda.LocalDatePeriodCountCalculator.java

License:Apache License

public double yearDiff(final LocalDate start, final LocalDate end, final PeriodCountBasis basis) {
    double diff = 0.0;

    switch (basis) {
    case ACT_ACT:
        final int startYear = start.getYear();
        final int endYear = end.getYear();
        if (startYear != endYear) {
            final LocalDate endOfStartYear = start.dayOfYear().withMaximumValue();
            final LocalDate startOfEndYear = end.withDayOfYear(1);

            final int diff1 = new Period(start, endOfStartYear, PeriodType.days()).getDays();
            final int diff2 = new Period(startOfEndYear, end, PeriodType.days()).getDays();
            diff = (diff1 + 1.0) / start.dayOfYear().getMaximumValue() + (endYear - startYear - 1.0)
                    + (double) diff2 / (double) end.dayOfYear().getMaximumValue();
        }/*from ww  w  . jav  a  2s.  c om*/
        break;

    case CONV_30_360:
    case CONV_360E_ISDA:
    case CONV_360E_ISMA:
    case ACT_360:
        diff = dayDiff(start, end, basis) / YEAR_360_0;
        break;

    case ACT_365:
        diff = dayDiff(start, end, basis) / YEAR_365_0;
        break;

    default:
        throw new UnsupportedOperationException("Sorry ACT_UST is not supported");
    }

    return diff;
}