Example usage for org.joda.time LocalDateTime dayOfMonth

List of usage examples for org.joda.time LocalDateTime dayOfMonth

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime dayOfMonth.

Prototype

public Property dayOfMonth() 

Source Link

Document

Get the day of month property which provides access to advanced functionality.

Usage

From source file:org.gnucash.android.ui.report.LineChartFragment.java

License:Apache License

/**
 * Returns entries which represent a user data of the specified account type
 * @param accountType account's type which user data will be processed
 * @return entries which represent a user data
 *///from w  w  w. j a  v  a  2 s  .  c  om
private List<Entry> getEntryList(AccountType accountType) {
    List<String> accountUIDList = new ArrayList<>();
    for (Account account : mAccountsDbAdapter.getSimpleAccountList()) {
        if (account.getAccountType() == accountType && !account.isPlaceholderAccount()
                && account.getCurrency() == mCurrency) {
            accountUIDList.add(account.getUID());
        }
    }

    LocalDateTime earliest;
    LocalDateTime latest;
    if (mReportStartTime == -1 && mReportEndTime == -1) {
        earliest = new LocalDateTime(mEarliestTimestampsMap.get(accountType));
        latest = new LocalDateTime(mLatestTimestampsMap.get(accountType));
    } else {
        earliest = new LocalDateTime(mReportStartTime);
        latest = new LocalDateTime(mReportEndTime);
    }
    Log.d(TAG, "Earliest " + accountType + " date " + earliest.toString("dd MM yyyy"));
    Log.d(TAG, "Latest " + accountType + " date " + latest.toString("dd MM yyyy"));

    int xAxisOffset = getDateDiff(new LocalDateTime(mEarliestTransactionTimestamp), earliest);
    int count = getDateDiff(earliest, latest);
    List<Entry> values = new ArrayList<>(count + 1);
    for (int i = 0; i <= count; i++) {
        long start = 0;
        long end = 0;
        switch (mGroupInterval) {
        case QUARTER:
            int quarter = getQuarter(earliest);
            start = earliest.withMonthOfYear(quarter * 3 - 2).dayOfMonth().withMinimumValue().millisOfDay()
                    .withMinimumValue().toDate().getTime();
            end = earliest.withMonthOfYear(quarter * 3).dayOfMonth().withMaximumValue().millisOfDay()
                    .withMaximumValue().toDate().getTime();

            earliest = earliest.plusMonths(3);
            break;
        case MONTH:
            start = earliest.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toDate()
                    .getTime();
            end = earliest.dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            earliest = earliest.plusMonths(1);
            break;
        case YEAR:
            start = earliest.dayOfYear().withMinimumValue().millisOfDay().withMinimumValue().toDate().getTime();
            end = earliest.dayOfYear().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            earliest = earliest.plusYears(1);
            break;
        }
        float balance = (float) mAccountsDbAdapter.getAccountsBalance(accountUIDList, start, end).asDouble();
        values.add(new Entry(balance, i + xAxisOffset));
        Log.d(TAG, accountType + earliest.toString(" MMM yyyy") + ", balance = " + balance);

    }

    return values;
}

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

License:Apache License

@Override
protected void updateDays() {
    LocalDateTime localDateTime = getCurrentCopticDate();
    setUpDayPicker(localDateTime.getDayOfMonth(), localDateTime.dayOfMonth().getMaximumValue());
}

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

License:Apache License

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

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

License:Apache License

private LocalDateTime getCurrentCopticDate() {
    int copticDay = getDay();
    int copticMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int copticYear = getYear();

    LocalDateTime copticDate = new LocalDateTime(copticYear, copticMonth + 1, 1, 0, 0, 0, 0,
            CopticChronology.getInstance());
    if (copticDay > copticDate.dayOfMonth().getMaximumValue()) {
        copticDay = copticDate.dayOfMonth().getMaximumValue();
    }//ww  w.  java2 s .  c o  m

    return new LocalDateTime(copticYear, copticMonth + 1, copticDay, 0, 0, 0, 0,
            CopticChronology.getInstance());
}

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

License:Apache License

@Override
protected void updateDays() {
    LocalDateTime localDateTime = getCurrentEthiopianDate();
    setUpDayPicker(localDateTime.getDayOfMonth(), localDateTime.dayOfMonth().getMaximumValue());
}

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

License:Apache License

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

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

License:Apache License

private LocalDateTime getCurrentEthiopianDate() {
    int ethiopianDay = getDay();
    int ethiopianMonth = Arrays.asList(monthsArray).indexOf(getMonth());
    int ethiopianYear = getYear();

    LocalDateTime ethiopianDate = new LocalDateTime(ethiopianYear, ethiopianMonth + 1, 1, 0, 0, 0, 0,
            EthiopicChronology.getInstance());
    if (ethiopianDay > ethiopianDate.dayOfMonth().getMaximumValue()) {
        ethiopianDay = ethiopianDate.dayOfMonth().getMaximumValue();
    }//from  w  w  w  .  j a  v  a2  s  .  c om

    return new LocalDateTime(ethiopianYear, ethiopianMonth + 1, ethiopianDay, 0, 0, 0, 0,
            EthiopicChronology.getInstance());
}

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

License:Apache License

@Override
protected void updateDays() {
    LocalDateTime localDateTime = getCurrentIslamicDate();
    setUpDayPicker(localDateTime.getDayOfMonth(), localDateTime.dayOfMonth().getMaximumValue());
}

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();
    }/* w w  w .jav  a  2  s.c  o m*/

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