List of usage examples for org.joda.time DateTimeFieldType year
public static DateTimeFieldType year()
From source file:ch.opentrainingcenter.client.views.ngchart.DynamicChartViewPart.java
License:Open Source License
private SimplePair<Date> getStartEnd() { final XAxisChart xAxis = XAxisChart.getByIndex(tagMonatJahrCombo.getSelectionIndex()); final boolean year = XAxisChart.YEAR.equals(xAxis); final boolean yearTillNow = XAxisChart.YEAR_START_TILL_NOW.equals(xAxis); Date start = dateVon.getDate().toDate();// von.toDate(); Date end = dateBis.getDate().toDate();// DateTime.now().toDate(); dateVon.setEnabled(!(yearTillNow || year)); dateBis.setEnabled(!year);//w w w . j a v a 2s. c om if (yearTillNow || year) { final int yStart = new DateTime(end.getTime()).get(DateTimeFieldType.year()); start = TimeHelper.getDate(yStart, 0, 1); dateVon.setEnabled(false); } if (year) { final int yEnd = new DateTime(end.getTime()).get(DateTimeFieldType.year()); end = TimeHelper.getDate(yEnd, 11, 31); dateBis.setEnabled(false); } return new SimplePair<Date>(start, end); }
From source file:com.google.code.tickconverter.convert.ConvertAdapter.java
License:Open Source License
/** * This method is the main method of the convert process. While the {@link BlockingQueue} of {@link IDukascopyRO} * have for 10 seconds no objects in the {@link BlockingQueue} add this method this object into the * {@link MetatraderConverter}. If an {@link InvalidTimeException} will threw the converter put a new * {@link MetatraderBean} into the {@link BlockingQueue} of {@link IMetatraderRO} and get the information of the * values from the {@link MetatraderConverter} object. * /* w ww. j a va 2s. c o m*/ * @throws InterruptedException will threw if {@link Thread#interrupt()} is called in the poll phase * @throws InvalidTimeException will threw if {@link MetatraderConverter#incrementInterval()} have a low range for * the new object after the creation of a new {@link MetatraderBean} */ public void convertProcess() throws InterruptedException { while (true) { IDukascopyRO object = dukaQueue.poll(2, TimeUnit.SECONDS); LoggerUtils.createDebugLog("poll object: " + object); if (null == object) { if (null != converter && converter.hasElements()) { putMetatraderObject(); } break; } if (null == converter) { DateTime timestamp = object.getTimeStamp(); DateTime start = new DateTime(timestamp.get(DateTimeFieldType.year()), timestamp.get(DateTimeFieldType.monthOfYear()), timestamp.get(DateTimeFieldType.dayOfMonth()), timestamp.get(DateTimeFieldType.hourOfDay()), timestamp.get(DateTimeFieldType.minuteOfHour())); converter = new MetatraderConverter(start, Period.minutes(1)); } try { converter.addDukascopy(object); } catch (InvalidTimeException e) { putMetatraderObject(); incrementWhileAdd(object); } } }
From source file:com.veeduria.dosfases.jsf.InconsPrespJSFBean.java
private void cargarPlanCGXInc() { lstTablaPlanCG.clear();/*ww w . ja v a 2 s. com*/ PreCmgastoinicial pc = tablaLogInconsSel.getAl().getGerId().getGinId(); SysRegistrocarga src = tablaLogInconsSel.getAl().getGerId().getGinId().getLgregId(); DateTime dtPeriodo = new DateTime(src.getLgregPeriodo()); cdfsfb.getLstPCGXCuentaXVig(pc.getGinCodcuenta(), dtPeriodo.get(DateTimeFieldType.year())).stream() .map((e -> { return new TablaPlanCG(e); })).forEach(lstTablaPlanCG::add); }
From source file:com.veeduria.dosfases.jsf.InconsPrespJSFBean.java
private void cargarTblGasInc() { lstTablapcginc.clear();//from w w w. j a va 2 s.com 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();/*from w w w .j a va 2 s . c o m*/ 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:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.TimeMLDateTimePoint.java
License:Open Source License
public void setField(Granulaarsus field, int value) { // ------ Time if (field == Granulaarsus.AM_PM) { try {/* ww w . j av a 2 s . c om*/ this.underlyingTime = (this.underlyingTime).withField(DateTimeFieldType.halfdayOfDay(), value); updateTimeRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.HOUR_OF_HALF_DAY) { try { if (value == 12) { value = 0; } this.underlyingTime = (this.underlyingTime).withField(DateTimeFieldType.hourOfHalfday(), value); // NB! Tunni seadistamisel nullime ka minutid, et ei tekiks nt ankurdamisel kummalisi vrtuseid this.underlyingTime = (this.underlyingTime).withField(DateTimeFieldType.minuteOfHour(), 0); updateTimeRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.MINUTE) { try { this.underlyingTime = (this.underlyingTime).withField(DateTimeFieldType.minuteOfHour(), value); updateTimeRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } // ------ Kuup2evad ja n2dalad if (field == Granulaarsus.DAY_OF_WEEK) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.dayOfWeek(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.WEEK_OF_YEAR) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.weekOfWeekyear(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.DAY_OF_MONTH) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.dayOfMonth(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.MONTH) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.monthOfYear(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.YEAR) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.year(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.YEAR_OF_CENTURY) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.yearOfCentury(), value); dateModified = true; // NB! Toimib nagu tavalise aastaarvu muutmine updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } if (field == Granulaarsus.CENTURY_OF_ERA) { try { this.underlyingDate = (this.underlyingDate).withField(DateTimeFieldType.centuryOfEra(), value); dateModified = true; updateDateRepresentation(field, null, false, SET_TYPE_OPERATION); } catch (Exception e) { } } }
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();/*from w ww .j a va 2 s. c o 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:net.karlmartens.platform.datatable.DataTableCell.java
License:Apache License
private static JsonElement creasteJsonElement(Object o) { if (o == null) return JsonNull.INSTANCE; if (o instanceof String) return new JsonPrimitive((String) o); if (o instanceof Boolean) return new JsonPrimitive((Boolean) o); if (o instanceof Number) return new JsonPrimitive((Number) o); if (o instanceof BaseLocal) { final BaseLocal date = (BaseLocal) o; final JsonObject json = new JsonObject(); json.add("year", createJsonElement(DateTimeFieldType.year(), date)); json.add("month", createJsonElement(DateTimeFieldType.monthOfYear(), date)); json.add("day", createJsonElement(DateTimeFieldType.dayOfMonth(), date)); json.add("hour", createJsonElement(DateTimeFieldType.hourOfDay(), date)); json.add("minute", createJsonElement(DateTimeFieldType.minuteOfHour(), date)); json.add("second", createJsonElement(DateTimeFieldType.secondOfMinute(), date)); json.add("millis", createJsonElement(DateTimeFieldType.millisOfSecond(), date)); return json; }//from ww w . j a v a2 s.c o m throw new UnsupportedOperationException(); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.coordinator.tutor.ChangeTutorship.java
License:Open Source License
public List<TutorshipErrorBean> run(String executionDegreeID, List<ChangeTutorshipBean> beans) throws FenixServiceException { final ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeID); final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan(); List<TutorshipErrorBean> studentsWithErrors = new ArrayList<TutorshipErrorBean>(); for (ChangeTutorshipBean bean : beans) { Tutorship tutorship = bean.getTutorship(); Partial newTutorshipEndDate = new Partial( new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] { bean.getTutorshipEndYear(), bean.getTutorshipEndMonth().getNumberOfMonth() }); if (tutorship.getEndDate() != null && tutorship.getEndDate().isEqual(newTutorshipEndDate)) { continue; }//from w w w . j a v a 2 s. c o m Registration registration = tutorship.getStudentCurricularPlan().getRegistration(); Integer studentNumber = registration.getNumber(); try { validateStudentRegistration(registration, executionDegree, degreeCurricularPlan, studentNumber); tutorship.setEndDate(newTutorshipEndDate); } catch (FenixServiceException ex) { studentsWithErrors.add(new TutorshipErrorBean(ex.getMessage(), ex.getArgs())); } } return studentsWithErrors; }
From source file:net.sourceforge.fenixedu.dataTransferObject.manager.academicCalendarManagement.CalendarEntryBean.java
License:Open Source License
public static Partial getPartialFromString(String date) { Integer month = Integer.valueOf(date.substring(0, 2)); Integer year = Integer.valueOf(date.substring(2)); return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] { year.intValue(), month.intValue() }); }