List of usage examples for org.joda.time Period toString
public String toString(PeriodFormatter formatter)
From source file:net.tourbook.common.time.TimeTools.java
License:Open Source License
/** * @return Returns the time zone offset for the default time zone. *///from w ww.j ava 2 s . c o m public static String getDefaultTimeZoneOffset() { final ZonedDateTime zdt = ZonedDateTime.now(); final int tzOffset = zdt.getOffset().getTotalSeconds(); final Period period = new Period(tzOffset * 1000); return period.toString(DURATION_FORMATTER); }
From source file:net.tourbook.common.time.TimeTools.java
License:Open Source License
/** * @param duration/* w w w . j a v a2 s . c o m*/ * in milliseconds. * @return */ public static String printDSTDuration(final long duration) { final Period period = new Period(duration); return period.toString(DURATION_FORMATTER); }
From source file:net.tourbook.device.garmin.fit.PrefPageImportFit.java
License:Open Source License
private void updateUI_SplitTour() { final long duration = _spinnerExceededDuration.getSelection(); final Period tourPeriod = new Period(0, duration * 1000, _tourPeriodTemplate); _lblSplitTour_DurationUnit.setText(tourPeriod.toString(UI.DEFAULT_DURATION_FORMATTER_SHORT)); }
From source file:net.tourbook.importdata.DialogEasyImportConfig.java
License:Open Source License
private void updateUI_TemperatureAdjustmentDuration() { final long duration = _spinnerIL_TemperatureAdjustmentDuration.getSelection(); final Period durationPeriod = new Period(0, duration * 1000, _durationTemplate); _lblIL_TemperatureAdjustmentDuration_Unit.setText(durationPeriod.toString(UI.DEFAULT_DURATION_FORMATTER)); }
From source file:net.tourbook.tour.DialogAdjustTemperature_Wizard.java
License:Open Source License
private IRunnableWithProgress performFinish_getRunnable() { _wizardPage.saveState();// ww w .j av a 2s. c o m final float avgTemperature = _prefStore.getFloat(ITourbookPreferences.ADJUST_TEMPERATURE_AVG_TEMPERATURE); final int durationTime = _prefStore.getInt(ITourbookPreferences.ADJUST_TEMPERATURE_DURATION_TIME); final float temperature = UI.convertTemperatureFromMetric(avgTemperature); final Period durationPeriod = new Period(0, durationTime * 1000, _durationTemplate); final String logText = NLS.bind(TourManager.LOG_TEMP_ADJUST_001_START, new Object[] { durationPeriod.toString(UI.DEFAULT_DURATION_FORMATTER), _nf1.format(temperature), UI.UNIT_LABEL_TEMPERATURE }); TourLogManager.addLog(TourLogState.DEFAULT, logText); final IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.Dialog_AdjustTemperature_Label_Progress_Task, _selectedTours.size()); // sort tours by date Collections.sort(_selectedTours); int workedTours = 0; final ArrayList<TourData> savedTours = new ArrayList<TourData>(); for (final TourData tourData : _selectedTours) { if (monitor.isCanceled()) { break; } monitor.worked(1); monitor.subTask(NLS.bind(Messages.Dialog_AdjustTemperature_Label_Progress_SubTask, ++workedTours, _selectedTours.size())); final float oldTourAvgTemperature = tourData.getAvgTemperature(); // skip tours which avg temperature is above the minimum avg temperature if (oldTourAvgTemperature > avgTemperature) { TourLogManager.logSubInfo(String.format( TourManager.LOG_TEMP_ADJUST_006_IS_ABOVE_TEMPERATURE, TourManager.getTourDateTimeShort(tourData), oldTourAvgTemperature, avgTemperature)); continue; } if (TourManager.adjustTemperature(tourData, durationTime)) { // tour is modified, save it final TourData savedTourData = TourManager.saveModifiedTour(tourData, false); if (savedTourData != null) { savedTours.add(savedTourData); } } } // update the UI if (savedTours.size() > 0) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { Util.clearSelection(); /* * Ensure the tour data editor contains the correct tour data */ TourData tourDataInEditor = null; final TourDataEditorView tourDataEditor = TourManager.getTourDataEditor(); if (tourDataEditor != null) { tourDataInEditor = tourDataEditor.getTourData(); } final TourEvent tourEvent = new TourEvent(savedTours); tourEvent.tourDataEditorSavedTour = tourDataInEditor; TourManager.fireEvent(TourEventId.TOUR_CHANGED, tourEvent); // do a reselection of the selected tours to fire the multi tour data selection _tourProvider.toursAreModified(savedTours); } }); } } }; return runnable; }
From source file:net.tourbook.tour.DialogAdjustTemperature_WizardPage.java
License:Open Source License
private void updateUI_TemperatureAdjustmentDuration() { final long duration = _spinnerTemperatureAdjustmentDuration.getSelection(); final Period tourPeriod = new Period(0, duration * 1000, _durationTemplate); _lblDurationUnit.setText(tourPeriod.toString(UI.DEFAULT_DURATION_FORMATTER)); }
From source file:net.tourbook.tour.photo.TourPhotoLinkView.java
License:Open Source License
/** * column: duration time/* w w w . j av a 2 s . com*/ */ private void defineColumn_Time_TourDurationTime() { final ColumnDefinition colDef = TableColumnFactory.TIME_TOUR_DURATION_TIME.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourPhotoLink link = (TourPhotoLink) cell.getElement(); final Period period = link.tourPeriod; int periodSum = 0; for (final int value : period.getValues()) { periodSum += value; } if (periodSum == 0) { // < 1 h cell.setText(Messages.Photos_AndTours_Label_DurationLess1Hour); } else { // > 1 h cell.setText(period.toString(_durationFormatter)); } setBgColor(cell, link); } }); }
From source file:net.tourbook.tour.TourInfoUI.java
License:Open Source License
private void updateUI() { /*/*from www . j av a 2 s. c om*/ * upper/lower part */ if (_lblTourType != null && _lblTourType.isDisposed() == false) { _lblTourType.setToolTipText(_uiTourTypeName); net.tourbook.ui.UI.updateUI_TourType(_tourData, _lblTourType, false); } String tourTitle = _tourData.getTourTitle(); if (tourTitle == null || tourTitle.trim().length() == 0) { tourTitle = Messages.Tour_Tooltip_Label_DefaultTitle; } _lblTitle.setText(tourTitle); if (_hasWeather) { _txtWeather.setText(_tourData.getWeather()); } if (_hasTourType) { _lblTourTypeText.setText(_tourData.getTourType().getName()); } if (_hasTags) { net.tourbook.ui.UI.updateUI_Tags(_tourData, _lblTourTags); } if (_hasDescription) { _txtDescription.setText(_tourData.getTourDescription()); } /* * column: left */ final long recordingTime = _tourData.getTourRecordingTime(); final long movingTime = _tourData.getTourDrivingTime(); final long breakTime = recordingTime - movingTime; final ZonedDateTime zdtTourStart = _tourData.getTourStartTime(); final ZonedDateTime zdtTourEnd = zdtTourStart.plusSeconds(recordingTime); if (isSimpleTour()) { // < 1 day _lblDate.setText(String.format(// Messages.Tour_Tooltip_Format_DateWeekTime, zdtTourStart.format(TimeTools.Formatter_Date_F), zdtTourStart.format(TimeTools.Formatter_Time_M), zdtTourEnd.format(TimeTools.Formatter_Time_M), zdtTourStart.get(TimeTools.calendarWeek.weekOfWeekBasedYear()) )); _lblRecordingTimeHour.setVisible(true); _lblMovingTimeHour.setVisible(true); _lblBreakTimeHour.setVisible(true); _lblRecordingTime.setText(FormatManager.formatRecordingTime(recordingTime)); _lblMovingTime.setText(FormatManager.formatDrivingTime(movingTime)); _lblBreakTime.setText(FormatManager.formatPausedTime(breakTime)); /* * Time zone */ final String tourTimeZoneId = _tourData.getTimeZoneId(); final TourDateTime tourDateTime = _tourData.getTourDateTime(); _lblTimeZone_Value.setText(tourTimeZoneId == null ? UI.EMPTY_STRING : tourTimeZoneId); _lblTimeZoneDifference_Value.setText(tourDateTime.timeZoneOffsetLabel); // set tooltip text final String defaultTimeZoneId = _prefStoreCommon.getString(ICommonPreferences.TIME_ZONE_LOCAL_ID); final String timeZoneTooltip = NLS.bind(Messages.ColumnFactory_TimeZoneDifference_Tooltip, defaultTimeZoneId); _lblTimeZoneDifference.setToolTipText(timeZoneTooltip); _lblTimeZoneDifference_Value.setToolTipText(timeZoneTooltip); _decoTimeZone.setDescriptionText(timeZoneTooltip); } else { // > 1 day _lblDate.setText(String.format(// Messages.Tour_Tooltip_Format_HistoryDateTime, zdtTourStart.format(_dtHistoryFormatter), zdtTourEnd.format(_dtHistoryFormatter)// )); // hide labels, they are displayed with the period values _lblRecordingTimeHour.setVisible(false); _lblMovingTimeHour.setVisible(false); _lblBreakTimeHour.setVisible(false); final Period recordingPeriod = new Period(_tourData.getTourStartTimeMS(), _tourData.getTourEndTimeMS(), _tourPeriodTemplate); final Period movingPeriod = new Period(0, movingTime * 1000, _tourPeriodTemplate); final Period breakPeriod = new Period(0, breakTime * 1000, _tourPeriodTemplate); _lblRecordingTime.setText(recordingPeriod.toString(UI.DEFAULT_DURATION_FORMATTER_SHORT)); _lblMovingTime.setText(movingPeriod.toString(UI.DEFAULT_DURATION_FORMATTER_SHORT)); _lblBreakTime.setText(breakPeriod.toString(UI.DEFAULT_DURATION_FORMATTER_SHORT)); } int windSpeed = _tourData.getWeatherWindSpeed(); windSpeed = (int) (windSpeed / net.tourbook.ui.UI.UNIT_VALUE_DISTANCE); _lblWindSpeed.setText(Integer.toString(windSpeed)); _lblWindSpeedUnit.setText(String.format(Messages.Tour_Tooltip_Format_WindSpeedUnit, UI.UNIT_LABEL_SPEED, IWeather.windSpeedTextShort[getWindSpeedTextIndex(windSpeed)])); // wind direction final int weatherWindDirDegree = _tourData.getWeatherWindDir(); _lblWindDirection.setText(Integer.toString(weatherWindDirDegree)); _lblWindDirectionUnit.setText(String.format(Messages.Tour_Tooltip_Format_WindDirectionUnit, IWeather.windDirectionText[getWindDirectionTextIndex(weatherWindDirDegree)])); // temperature float temperature = _tourData.getAvgTemperature(); if (net.tourbook.ui.UI.UNIT_VALUE_TEMPERATURE != 1) { temperature = temperature * net.tourbook.ui.UI.UNIT_FAHRENHEIT_MULTI + net.tourbook.ui.UI.UNIT_FAHRENHEIT_ADD; } _lblTemperature.setText(_nf1.format(temperature)); // weather clouds final int weatherIndex = _tourData.getWeatherIndex(); final String cloudText = IWeather.cloudText[weatherIndex]; final String cloudImageName = IWeather.cloudIcon[weatherIndex]; _lblClouds.setImage(UI.IMAGE_REGISTRY.get(cloudImageName)); _lblCloudsUnit.setText(cloudText.equals(IWeather.cloudIsNotDefined) ? UI.EMPTY_STRING : cloudText); /* * column: right */ final float distance = _tourData.getTourDistance() / net.tourbook.ui.UI.UNIT_VALUE_DISTANCE; _lblDistance.setText(FormatManager.formatDistance(distance / 1000.0)); _lblDistanceUnit.setText(UI.UNIT_LABEL_DISTANCE); _lblAltitudeUp.setText(Integer.toString(// (int) (_tourData.getTourAltUp() / net.tourbook.ui.UI.UNIT_VALUE_ALTITUDE))); _lblAltitudeUpUnit.setText(UI.UNIT_LABEL_ALTITUDE); _lblAltitudeDown.setText(Integer.toString(// (int) (_tourData.getTourAltDown() / net.tourbook.ui.UI.UNIT_VALUE_ALTITUDE))); _lblAltitudeDownUnit.setText(UI.UNIT_LABEL_ALTITUDE); final float avgSpeed = movingTime == 0 ? 0 : distance / (movingTime / 3.6f); _lblAvgSpeed.setText(FormatManager.formatSpeed(avgSpeed)); _lblAvgSpeedUnit.setText(UI.UNIT_LABEL_SPEED); final int pace = (int) (distance == 0 ? 0 : (movingTime * 1000 / distance)); _lblAvgPace.setText(String.format(// Messages.Tour_Tooltip_Format_Pace, pace / 60, pace % 60)// ); _lblAvgPaceUnit.setText(UI.UNIT_LABEL_PACE); // avg pulse final double avgPulse = _tourData.getAvgPulse(); _lblAvgPulse.setText(FormatManager.formatPulse(avgPulse)); _lblAvgPulseUnit.setText(Messages.Value_Unit_Pulse); // avg cadence final double avgCadence = _tourData.getAvgCadence() * _tourData.getCadenceMultiplier(); _lblAvgCadence.setText(FormatManager.formatCadence(avgCadence)); _lblAvgCadenceUnit .setText(_tourData.isCadenceSpm() ? Messages.Value_Unit_Cadence_Spm : Messages.Value_Unit_Cadence); // avg power final double avgPower = _tourData.getPower_Avg(); _lblAvg_Power.setText(FormatManager.formatPower(avgPower)); _lblAvg_PowerUnit.setText(UI.UNIT_POWER); // calories final double calories = _tourData.getCalories(); _lblCalories.setText(FormatManager.formatNumber_0(calories)); // body _lblRestPulse.setText(Integer.toString(_tourData.getRestPulse())); _lblBodyWeight.setText(_nf1.format(_tourData.getBodyWeight())); /* * Max values */ _lblMaxAltitude.setText(Integer.toString(// (int) (_tourData.getMaxAltitude() / net.tourbook.ui.UI.UNIT_VALUE_ALTITUDE))); _lblMaxAltitudeUnit.setText(UI.UNIT_LABEL_ALTITUDE); _lblMaxPulse.setText(FormatManager.formatPulse(_tourData.getMaxPulse())); _lblMaxPulseUnit.setText(Messages.Value_Unit_Pulse); _lblMaxSpeed.setText(FormatManager.formatSpeed(_tourData.getMaxSpeed())); _lblMaxSpeedUnit.setText(UI.UNIT_LABEL_SPEED); // gears if (_hasGears) { _lblGearFrontShifts.setText(Integer.toString(_tourData.getFrontShiftCount())); _lblGearRearShifts.setText(REAR_SHIFT_FORMAT + Integer.toString(_tourData.getRearShiftCount())); } /* * date/time */ // date/time created if (_uiDtCreated != null) { _lblDateTimeCreatedValue.setText(_uiDtCreated == null ? // UI.EMPTY_STRING : _uiDtCreated.format(TimeTools.Formatter_DateTime_M)); } // date/time modified if (_uiDtModified != null) { _lblDateTimeModifiedValue.setText(_uiDtModified == null ? // UI.EMPTY_STRING : _uiDtModified.format(TimeTools.Formatter_DateTime_M)); } }
From source file:net.tourbook.ui.views.rawData.RawDataView.java
License:Open Source License
private String getDurationText(final ImportLauncher importLauncher) { final int duration = importLauncher.temperatureAdjustmentDuration; final Period durationPeriod = new Period(0, duration * 1000, _durationTemplate); return durationPeriod.toString(UI.DEFAULT_DURATION_FORMATTER); }
From source file:org.apache.drill.exec.vector.complex.fn.BasicJsonOutput.java
License:Apache License
@Override public void writeInterval(Period value) throws IOException { gen.writeString(value.toString(ISOPeriodFormat.standard())); }