List of usage examples for org.joda.time Duration Duration
public Duration(Object duration)
From source file:com.kopysoft.chronos.adapter.clock.PayPeriodAdapterList.java
License:Open Source License
@Deprecated public Duration getTime() { Duration dur = new Duration(0); for (DateTime date : gPunchesByDay.getDays()) { dur = dur.plus(getTime(gPunchesByDay.getPunchPair(date))); }//from ww w. j a va 2s .c o m if (enableLog) Log.d(TAG, "Duration: " + dur); return dur; }
From source file:com.kopysoft.chronos.adapter.clock.PayPeriodAdapterList.java
License:Open Source License
public static Duration getTime(PunchTable table) { Duration dur = new Duration(0); for (DateTime date : table.getDays()) { dur = dur.plus(getTime(table.getPunchPair(date))); }//w w w . j a v a 2 s. c o m if (enableLog) Log.d(TAG, "Duration: " + dur); return dur; }
From source file:com.kopysoft.chronos.adapter.clock.PayPeriodAdapterList.java
License:Open Source License
public static Duration getTime(List<PunchPair> punches, boolean allowNegative) { Duration dur = new Duration(0); for (PunchPair pp : punches) { if (enableLog) Log.d(TAG, "Punch Size: " + pp.getDuration()); if (!pp.getInPunch().getTask().getEnablePayOverride()) dur = dur.plus(pp.getDuration()); else if (pp.getInPunch().getTask().getPayOverride() > 0) dur = dur.plus(pp.getDuration()); else/*from w w w . java 2s . c o m*/ dur = dur.minus(pp.getDuration()); } if (dur.getMillis() < 0 && !allowNegative) dur = new Duration(0); return dur; }
From source file:com.kopysoft.chronos.adapter.clock.TodayAdapterPair.java
License:Open Source License
public static Duration getTime(List<PunchPair> punches, boolean allowNegative) { Duration dur = new Duration(0); for (PunchPair pp : punches) { if (enableLog) Log.d(TAG, "Punch Size: " + pp.getDuration()); if (!pp.getInPunch().getTask().getEnablePayOverride()) dur = dur.plus(pp.getDuration()); else if (pp.getTask().getPayOverride() == 0) continue; else if (pp.getInPunch().getTask().getPayOverride() > 0) dur = dur.plus(pp.getDuration()); else/*www. j a va2 s .c o m*/ dur = dur.minus(pp.getDuration()); } if (dur.getMillis() < 0 && !allowNegative) dur = new Duration(0); return dur; }
From source file:com.kopysoft.chronos.lib.Email.java
License:Open Source License
public String getBriefView() { String retString = ""; List<DateTime> dates = punchTable.getDays(); Chronos chron = new Chronos(gContext); Duration totalDuration = new Duration(0); for (DateTime date : dates) { DateTimeFormatter fmt = DateTimeFormat.forPattern("E, MMM d, yyyy"); String time = fmt.print(date); Duration dur = PayPeriodAdapterList.getTime(punchTable.getPunchPair(date)); retString += time/*w ww .j a va2s . c o m*/ + String.format(" - %02d:%02d\n", dur.toPeriod().getHours(), dur.toPeriod().getMinutes()); totalDuration = totalDuration.plus(dur); Note note = chron.getNoteByDay(date); if (!note.getNote().equalsIgnoreCase("")) { retString += "\tNote: " + note.getNote() + "\n"; } } retString += String.format("Total time - %02d:%02d\n", totalDuration.getStandardHours(), totalDuration.getStandardMinutes() % 60); chron.close(); return retString; }
From source file:com.kopysoft.chronos.lib.Email.java
License:Open Source License
public String getExpandedView() { String retString = ""; List<DateTime> dates = punchTable.getDays(); DateTimeFormatter dateFormat = DateTimeFormat.forPattern("E, MMM d, yyyy:\n"); DateTimeFormatter fmt;/*from w w w .j a v a 2 s. c om*/ if (!DateFormat.is24HourFormat(gContext)) fmt = DateTimeFormat.forPattern("h:mm a"); else fmt = DateTimeFormat.forPattern("HH:mm"); Chronos chron = new Chronos(gContext); Duration totalDuration = new Duration(0); for (DateTime date : dates) { if (punchTable.getPunchPair(date).size() > 0) retString += dateFormat.print(date); for (PunchPair pp : punchTable.getPunchPair(date)) { retString += "\t" + fmt.print(pp.getInPunch().getTime()) + " - \tIN - " + pp.getInPunch().getTask().getName() + "\n"; if (pp.getOutPunch() != null) { retString += "\t" + fmt.print(pp.getOutPunch().getTime()) + " - \tOUT - " + pp.getOutPunch().getTask().getName() + "\n"; } } totalDuration = totalDuration.plus(PayPeriodAdapterList.getTime(punchTable.getPunchPair(date))); Note note = chron.getNoteByDay(date); if (!note.getNote().equalsIgnoreCase("")) { retString += "\tNote: " + note.getNote() + "\n"; } } retString += String.format("Total time - %02d:%02d\n", totalDuration.getStandardHours(), totalDuration.getStandardMinutes() % 60); chron.close(); return retString; }
From source file:com.linkedin.pinot.common.metadata.segment.SegmentZKMetadata.java
License:Apache License
/** * NOTE: should be called after setting start and end time. *///from w ww . ja v a 2s . c o m public void setTimeUnit(@Nonnull TimeUnit timeUnit) { _timeUnit = timeUnit; _timeGranularity = new Duration(_timeUnit.toMillis(1)); // For consuming segment, end time might not be set if (_startTime >= 0 && _startTime <= _endTime) { _timeInterval = new Interval(_timeUnit.toMillis(_startTime), _timeUnit.toMillis(_endTime)); } }
From source file:com.linkedin.pinot.controller.helix.core.retention.strategy.TimeRetentionStrategy.java
License:Apache License
public TimeRetentionStrategy(String timeUnit, String timeValue) throws Exception { long retentionMillis = TimeUtils.toMillis(timeUnit, timeValue); if (retentionMillis == Long.MIN_VALUE) { LOGGER.error("Failed to set retention duration, timeUnit: {}, timeValue: {}", timeUnit, timeValue); _retentionDuration = null;/*from w w w. j av a 2 s . c o m*/ } else { _retentionDuration = new Duration(TimeUtils.toMillis(timeUnit, timeValue)); } }
From source file:com.linkedin.pinot.controller.helix.core.retention.strategy.TimeRetentionStrategy.java
License:Apache License
public TimeRetentionStrategy(TimeUnit retentionTimeUnit, int retentionTimeValue) { if (retentionTimeUnit != null && retentionTimeValue > 0) { _retentionDuration = new Duration(retentionTimeUnit.toMillis(retentionTimeValue)); } else {//from w w w .j av a 2 s . c o m _retentionDuration = null; } }
From source file:com.linkedin.pinot.core.segment.index.SegmentMetadataImpl.java
License:Apache License
private void setTimeIntervalAndGranularity() { if (_segmentMetadataPropertiesConfiguration.containsKey(V1Constants.MetadataKeys.Segment.SEGMENT_START_TIME) && _segmentMetadataPropertiesConfiguration .containsKey(V1Constants.MetadataKeys.Segment.SEGMENT_END_TIME) && _segmentMetadataPropertiesConfiguration .containsKey(V1Constants.MetadataKeys.Segment.TIME_UNIT)) { try {/*from www . ja v a 2s .c o m*/ TimeUnit segmentTimeUnit = TimeUtils .timeUnitFromString(_segmentMetadataPropertiesConfiguration.getString(TIME_UNIT)); _timeGranularity = new Duration(segmentTimeUnit.toMillis(1)); String startTimeString = _segmentMetadataPropertiesConfiguration .getString(V1Constants.MetadataKeys.Segment.SEGMENT_START_TIME); String endTimeString = _segmentMetadataPropertiesConfiguration .getString(V1Constants.MetadataKeys.Segment.SEGMENT_END_TIME); _timeInterval = new Interval(segmentTimeUnit.toMillis(Long.parseLong(startTimeString)), segmentTimeUnit.toMillis(Long.parseLong(endTimeString))); } catch (Exception e) { LOGGER.warn("Caught exception while setting time interval and granularity", e); _timeInterval = null; _timeGranularity = null; } } }