List of usage examples for org.joda.time Interval getStart
public DateTime getStart()
From source file:com.almende.eve.agent.MeetingAgent.java
License:Apache License
/** * Gets the office hours./*from www . java2 s.c o m*/ * * @param timeMin * the time min * @param timeMax * the time max * @return the office hours */ public ArrayNode getOfficeHours(@Name("timeMin") final String timeMin, @Name("timeMax") final String timeMax) { final List<Interval> available = IntervalsUtil.getOfficeHours(new DateTime(timeMin), new DateTime(timeMax)); // convert to JSON array final ArrayNode array = JOM.createArrayNode(); for (final Interval interval : available) { final ObjectNode obj = JOM.createObjectNode(); obj.put("start", interval.getStart().toString()); obj.put("end", interval.getEnd().toString()); array.add(obj); } return array; }
From source file:com.anasoft.os.daofusion.bitemporal.PersistentInterval.java
License:Apache License
public Object getPropertyValue(Object component, int property) throws HibernateException { Interval interval = (Interval) component; return (property == 0) ? interval.getStart().toDate() : interval.getEnd().toDate(); }
From source file:com.anasoft.os.daofusion.bitemporal.PersistentInterval.java
License:Apache License
public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, Hibernate.TIMESTAMP.sqlType()); statement.setNull(index + 1, Hibernate.TIMESTAMP.sqlType()); return;//w w w .j av a2 s. com } Interval interval = (Interval) value; statement.setTimestamp(index, asTimeStamp(interval.getStart())); statement.setTimestamp(index + 1, asTimeStamp(interval.getEnd())); }
From source file:com.citruspay.CommonUtil.java
License:Open Source License
/** * This function checks if the txncreated date falls between dailysettlementhr and dailysettlementmin .these two values are taken from properties file. * @param txnCreatedDate// w w w .j ava2 s . co m * @param dailySettlementHr * @param dailySettlementMin * @return */ public static boolean validateDateTime(Date txnCreatedDate) { Date currentDate = new Date(); DateTime currentDateTime = JDateUtil.getDateAndTime(currentDate); DateTime txnCreatedDateDateTime = JDateUtil.getDateAndTime(txnCreatedDate); // If transaction created time is more than a day old then take the record from DB. Interval lastDay = JDateUtil.getISTPreviousDay(); if (txnCreatedDateDateTime.compareTo(lastDay.getStart()) < 0) { return true; } // if it's same day transaction then return false and call corresponding PG's enquiry call else take the data from our DB if (JDateUtil.noOfDays(txnCreatedDateDateTime, currentDateTime) > 1) { return true; } else return false; // Is previous day transaction /*NO NEED to solve if ((txnCreatedDateDateTime.compareTo(lastDay.getStart()) >= 0 && txnCreatedDateDateTime.compareTo(lastDay.getEnd()) <= 0)) { return Boolean.FALSE; } return Boolean.TRUE; */ }
From source file:com.excilys.ebi.bank.dao.impl.OperationDaoImpl.java
License:Apache License
private BooleanExpression addOperationYearMonthExpression(BooleanExpression predicate, QOperation operation, YearMonth yearMonth) {// w ww.j a v a 2 s. c o m if (yearMonth == null) return predicate; else { Interval range = yearMonth.toInterval(); return predicate.and(operation.date.between(range.getStart(), range.getEnd())); } }
From source file:com.flipkart.foxtrot.core.querystore.impl.ElasticsearchUtils.java
License:Apache License
@VisibleForTesting public static String[] getIndices(final String table, final ActionRequest request, final Interval interval) { DateTime start = interval.getStart().toLocalDate().toDateTimeAtStartOfDay(); if (start.getYear() <= 1970) { logger.warn("Request of type {} running on all indices", request.getClass().getSimpleName()); return new String[] { getIndices(table) }; }//from w w w . j a v a 2 s . c o m List<String> indices = Lists.newArrayList(); final DateTime end = interval.getEnd().plusDays(1).toLocalDate().toDateTimeAtStartOfDay(); while (start.getMillis() < end.getMillis()) { final String index = getCurrentIndex(table, start.getMillis()); indices.add(index); start = start.plusDays(1); } logger.info("Request of type {} on indices: {}", request.getClass().getSimpleName(), indices); return indices.toArray(new String[indices.size()]); }
From source file:com.github.dbourdette.otto.data.DataTableUtils.java
License:Apache License
/** * Finds best Duration of rows for a {@link SimpleDataTable} based on given table interval *///from w w w .j av a 2s . c om public static Duration findBest(Interval interval) { Duration duration = new Duration(interval.getStart(), interval.getEnd()); if (duration.isShorterThan(ONE_DAY) || duration.equals(ONE_DAY)) { return Duration.standardMinutes(5); } else if (duration.isShorterThan(FIVE_DAYS) || duration.equals(FIVE_DAYS)) { return Duration.standardMinutes(30); } else { return Duration.standardDays(1); } }
From source file:com.github.dbourdette.otto.data.SimpleDataTable.java
License:Apache License
public void setupRows(Interval interval, Duration step) { rows.clear();/*from w w w .j a v a2 s.c o m*/ DateTime current = interval.getStart(); while (current.isBefore(interval.getEnd())) { rows.add(new SimpleDataTableRow(new Interval(current, step))); current = current.plus(step); } }
From source file:com.github.dbourdette.otto.web.util.RandomDateUtils.java
License:Apache License
public static DateTime in(Interval interval) { Random random = new Random(); long millis = (long) ((interval.getEndMillis() - interval.getStartMillis()) * random.nextDouble()); return interval.getStart().plus(millis); }
From source file:com.google.sampling.experiential.server.DSQueryBuilder.java
License:Open Source License
private void compareDateRange(String key, String range, DateTimeZone jodaTimeZone) { DateTime startDate = null;/*from w w w . ja va 2s .c om*/ DateTime endDate = null; boolean keyCannedDateRange = isKeyCannedDateRange(key); boolean rangeCannedDateRange = isCannedDateRange(range); if (keyCannedDateRange || rangeCannedDateRange) { String rangeName = null; if (keyCannedDateRange) { rangeName = key.substring(1); } else { rangeName = range; } Interval interval; if (rangeName.equals("last_week")) { interval = getLastWeek(jodaTimeZone); } else if (rangeName.equals("last_month")) { interval = getLast4Weeks(jodaTimeZone); } else { throw new IllegalArgumentException("Unknown date range"); } startDate = interval.getStart(); endDate = interval.getEnd().plusDays(1); } else { Iterable<String> iterable = Splitter.on("-").split(range); Iterator<String> iter = iterable.iterator(); if (!iter.hasNext()) { throw new IllegalArgumentException("Illformed Date Range: " + range); } String firstDate = iter.next(); String secondDate = null; if (iter.hasNext()) { secondDate = iter.next(); } startDate = newDateTimeFromString(firstDate, jodaTimeZone); endDate = null; if (secondDate != null && !secondDate.isEmpty()) { endDate = newDateTimeFromString(secondDate, jodaTimeZone).plusDays(1); } else { endDate = startDate.plusDays(1); } } jdoQuery.addFilters("when >= startDateParam", "when <= endDateParam"); jdoQuery.declareParameters("java.util.Date startDateParam", "java.util.Date endDateParam"); jdoQuery.addParameterObjects(startDate.toDate(), endDate.toDate()); }