Example usage for org.joda.time DateTime get

List of usage examples for org.joda.time DateTime get

Introduction

In this page you can find the example usage for org.joda.time DateTime get.

Prototype

public int get(DateTimeFieldType type) 

Source Link

Document

Get the value of one of the fields of a datetime.

Usage

From source file:com.veeduria.dosfases.jsf.InconsPrespJSFBean.java

private void cargarTblGasInc() {

    lstTablapcginc.clear();/*from   w  w  w.  java  2s  . c om*/

    cdfsfb.getLstInconsistenciasxArchivo(tablaSysRegistroCargaSel.getSysRegistrocarga().getLgregId()).stream()
            .map((gi) -> {
                TablaPrecmgastoinconsistencia tpgi = new TablaPrecmgastoinconsistencia(gi);
                DateTime dt = new DateTime(gi.getGinId().getLgregId().getLgregPeriodo());
                cdfsfb.getLstPCGXCuentaXVig(gi.getGinId().getGinCodcuenta(), dt.get(DateTimeFieldType.year()))
                        .stream().map((cp -> {
                            return new TablaPlanCG(cp);
                        })).forEach((tpgi.getLstTpcg()::add));

                return tpgi;
            }).forEach(lstTablapcginc::add);
}

From source file:com.veeduria.dosfases.jsf.InconsPrespJSFBean.java

private void cargarDetInconsistencia() {
    lstTablapcginc.clear();// w  w  w .j a  v  a2  s . com
    cdfsfb.getDetporInconsistencia(strDetalleIncons).stream().map((gi -> {
        TablaPrecmgastoinconsistencia tpgi = new TablaPrecmgastoinconsistencia(gi);
        DateTime dt = new DateTime(gi.getGinId().getLgregId().getLgregPeriodo());
        cdfsfb.getLstPCGXCuentaXVig(gi.getGinId().getGinCodcuenta(), dt.get(DateTimeFieldType.year())).stream()
                .map((cp -> {
                    return new TablaPlanCG(cp);
                })).forEach(tpgi.getLstTpcg()::add);

        return tpgi;
    })).forEach(lstTablapcginc::add);

    //        cdfsfb.getDetporInconsistencia(strDetalleIncons).stream().map((gi) -> {
    //            TablaPrecmgastoinconsistencia tpgi = new TablaPrecmgastoinconsistencia(gi);
    //            DateTime dt = new DateTime(gi.getGinId().getLgregId().getLgregPeriodo());
    //            for (CntPlancuetagastos cp : cdfsfb.getLstPCGXCuentaXVig(gi.getGinId().getGinCodcuenta(), dt.get(DateTimeFieldType.year()))) {
    //                tpgi.getLstTpcg().add(new TablaPlanCG(cp));
    //            }
    //            return gi;
    //        }).forEach((gi) -> {
    //            lstTablapcginc.add(new TablaPrecmgastoinconsistencia(gi));
    //        });
}

From source file:fr.nicopico.dashclock.birthday.BirthdayService.java

License:Apache License

@Override
protected void onUpdateData(int reason) {
    if (reason == UPDATE_REASON_SETTINGS_CHANGED) {
        updatePreferences();/* w  ww  . j a  va2  s. co  m*/
    }

    final Resources res = getResources();
    final List<Birthday> birthdays = birthdayRetriever.getContactWithBirthdays(getApplicationContext(),
            contactGroupId);

    Configuration config = new Configuration();
    config.setToDefaults();

    // Disable/enable Android localization
    if (needToRefreshLocalization
            || (disableLocalization && !DEFAULT_LANG.equals(Locale.getDefault().getLanguage()))) {
        if (disableLocalization) {
            config.locale = new Locale(DEFAULT_LANG);
        } else {
            // Restore Android localization
            //noinspection ConstantConditions
            config.locale = Resources.getSystem().getConfiguration().locale;
        }

        Locale.setDefault(config.locale);
        getBaseContext().getResources().updateConfiguration(config,
                getBaseContext().getResources().getDisplayMetrics());
    }

    DateTime today = new DateTime();

    int upcomingBirthdays = 0;
    String collapsedTitle = null;
    String expandedTitle = null;
    StringBuilder body = new StringBuilder();

    for (Birthday birthday : birthdays) {
        DateTime birthdayEvent;
        MonthDay birthdayDate = birthday.birthdayDate;
        try {
            birthdayEvent = birthdayDate.toDateTime(today);
        } catch (IllegalFieldValueException e) {
            if (birthdayDate.getDayOfMonth() == 29 && birthdayDate.getMonthOfYear() == 2) {
                // Birthday on February 29th (leap year) -> March 1st
                birthdayEvent = birthdayDate.dayOfMonth().addToCopy(1).toDateTime(today);
            } else {
                Log.e(TAG, "Invalid date", e);
                continue;
            }
        }

        // How many days before the birthday ?
        int days;
        if (birthdayEvent.isAfter(today) || birthdayEvent.isEqual(today)) {
            days = Days.daysBetween(today, birthdayEvent).getDays();
        } else {
            // Next birthday event is next year
            days = Days.daysBetween(today, birthdayEvent.plusYears(1)).getDays();
        }

        // Should the birthday be displayed ?
        if (days <= daysLimit) {
            upcomingBirthdays++;

            if (upcomingBirthdays == 1) {
                // A single birthday will be displayed
                collapsedTitle = birthday.displayName;
                expandedTitle = res.getString(R.string.single_birthday_title_format, birthday.displayName);
            }

            // More than 1 upcoming birthday: display contact name
            if (upcomingBirthdays > 1) {
                body.append("\n").append(birthday.displayName).append(", ");
            }

            // Age
            if (!birthday.unknownYear) {
                int age = today.get(DateTimeFieldType.year()) - birthday.year;
                body.append(res.getQuantityString(R.plurals.age_format, age, age));
                body.append(' ');
            }

            // When
            int daysFormatResId;
            switch (days) {
            case 0:
                daysFormatResId = R.string.when_today_format;
                break;
            case 1:
                daysFormatResId = R.string.when_tomorrow_format;
                break;
            default:
                daysFormatResId = R.string.when_days_format;
            }

            body.append(res.getString(daysFormatResId, days));
        } else {
            // All visible birthdays have been processed
            break;
        }
    }

    if (upcomingBirthdays > 0) {
        Intent clickIntent = buildClickIntent(birthdays.subList(0, upcomingBirthdays));

        if (upcomingBirthdays > 1) {
            collapsedTitle += " + " + (upcomingBirthdays - 1);
        }

        // Display message
        publishUpdate(
                new ExtensionData().visible(true).icon(R.drawable.ic_extension_white).status(collapsedTitle)
                        .expandedTitle(expandedTitle).expandedBody(body.toString()).clickIntent(clickIntent));
    } else {
        // Nothing to show
        publishUpdate(new ExtensionData().visible(false));
    }
}

From source file:gobblin.util.DatePartitionType.java

License:Open Source License

public int getField(DateTime dateTime) {
    return dateTime.get(this.dateTimeField);
}

From source file:org.apache.tajo.util.datetime.DateTimeUtil.java

License:Apache License

public static long getHour(DateTime dateTime) {
    return convertToMicroSeconds(
            dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()), 0, 0, 0));
}

From source file:org.apache.tajo.util.datetime.DateTimeUtil.java

License:Apache License

public static long getMinute(DateTime dateTime) {
    return convertToMicroSeconds(dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()),
            dateTime.get(org.joda.time.DateTimeFieldType.minuteOfHour()), 0, 0));
}

From source file:org.apache.tajo.util.datetime.DateTimeUtil.java

License:Apache License

public static long getSecond(DateTime dateTime) {
    return convertToMicroSeconds(dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()),
            dateTime.get(org.joda.time.DateTimeFieldType.minuteOfHour()),
            dateTime.get(org.joda.time.DateTimeFieldType.secondOfMinute()), 0));
}

From source file:org.apache.tajo.util.TimeStampUtil.java

License:Apache License

public static long getHour(DateTime dateTime) {
    return convertToMicroSeconds(dateTime.withTime(dateTime.get(DateTimeFieldType.clockhourOfDay()), 0, 0, 0));
}

From source file:org.apache.tajo.util.TimeStampUtil.java

License:Apache License

public static long getMinute(DateTime dateTime) {
    return convertToMicroSeconds(dateTime.withTime(dateTime.get(DateTimeFieldType.clockhourOfDay()),
            dateTime.get(DateTimeFieldType.minuteOfHour()), 0, 0));
}

From source file:org.apache.tajo.util.TimeStampUtil.java

License:Apache License

public static long getSecond(DateTime dateTime) {
    return convertToMicroSeconds(dateTime.withTime(dateTime.get(DateTimeFieldType.clockhourOfDay()),
            dateTime.get(DateTimeFieldType.minuteOfHour()), dateTime.get(DateTimeFieldType.secondOfMinute()),
            0));//ww  w .jav  a  2 s.c  o  m
}