List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:app.core.Employee.java
License:Open Source License
public Employee(String firstName, String lastName) { super(firstName, lastName); this.employeeNo = 0; this.employmentInterval = new Interval(new DateMidnight(), new DateMidnight(2099, 1, 1)); }
From source file:app.sunstreak.yourpisd.util.DateHelper.java
License:Open Source License
public static String timeSince(DateTime dt) { StringBuilder sb = new StringBuilder(); sb.append("Last updated "); Period pd = new Interval(dt.getMillis(), Instant.now().getMillis()).toPeriod(); if (pd.getDays() > 0) { sb.append(pd.getDays());/*from w w w . ja v a 2 s . com*/ return sb.append(" days ago").toString(); } if (pd.getHours() > 0) sb.append(pd.getHours() + "hours "); if (pd.getMinutes() > 0) { sb.append(pd.getMinutes() + " minutes"); return sb.append(" ago").toString(); } return sb.append("less than a minute ago").toString(); }
From source file:app.sunstreak.yourpisd.util.DateHelper.java
License:Open Source License
public static String daysRelative(DateTime dt) { while (dt.isBefore(startOfSchoolYear)) dt = dt.plusYears(1);//from w w w. j ava 2 s.c o m // if today if (dt.toLocalDate().isEqual(new LocalDate())) return "(today)"; Period pd; if (dt.isBeforeNow()) pd = new Interval(dt, new LocalDate().toDateTimeAtStartOfDay()).toPeriod(); else pd = new Interval(new LocalDate().toDateTimeAtStartOfDay(), dt).toPeriod(); StringBuilder sb = new StringBuilder("\n("); int compare = dt.compareTo(new DateTime()); sb.append(pf.print(pd)); // Compare to now. if (dt.isBeforeNow()) sb.append(" ago)"); else sb.append(" from now)"); return sb.toString(); }
From source file:au.id.hazelwood.xmltvguidebuilder.postprocessor.ListingVerifier.java
License:Apache License
public void verifyListing(ChannelListings listings, DateTime from, DateTime to, DateTime subsetTo) { Duration listingDurationTotal = new Interval(from, to).toDuration(); Duration listingDurationSubset = new Interval(from, subsetTo).toDuration(); LOGGER.info(repeat("-", 100)); for (ChannelDetail channelDetail : listings.getChannels()) { Duration missingDurationTotal = Duration.ZERO; Duration missingDurationSubset = Duration.ZERO; StringBuilder allMissingIntervalDetails = new StringBuilder(); for (Interval missing : findMissingIntervals(listings, from, to, channelDetail.getId())) { missingDurationTotal = missingDurationTotal.plus(missing.toDuration()); if (missing.getStart().isBefore(subsetTo)) { if (missing.getEnd().isBefore(subsetTo)) { missingDurationSubset = missingDurationSubset.plus(missing.toDuration()); } else { missingDurationSubset = missingDurationSubset .plus(new Duration(missing.getStart(), subsetTo)); }/*from ww w . j av a2 s. c o m*/ } allMissingIntervalDetails.append(allMissingIntervalDetails.length() == 0 ? "missing " : ", "); allMissingIntervalDetails.append( format("{0}-{1}", toISODateTime(missing.getStart()), toISODateTime(missing.getEnd()))); } Duration availableDurationTotal = listingDurationTotal.minus(missingDurationTotal); Duration availableDurationSubset = listingDurationSubset.minus(missingDurationSubset); Integer availablePercentageTotal = getPercentage(availableDurationTotal, listingDurationTotal); Integer availablePercentageSubset = getPercentage(availableDurationSubset, listingDurationSubset); LOGGER.info("{} {} [{}|{}] {}", rightPad(channelDetail.getId() + " - " + channelDetail.getName(), 42), formatDurationDHM(availableDurationTotal.getMillis()), leftPad(availablePercentageSubset + "%", 4), leftPad(availablePercentageTotal + "%", 4), allMissingIntervalDetails.toString()); } LOGGER.info(repeat("-", 100)); }
From source file:au.id.hazelwood.xmltvguidebuilder.postprocessor.ListingVerifier.java
License:Apache License
private List<Interval> findMissingIntervals(ChannelListings channelListings, DateTime from, DateTime to, Integer channelId) {//from w w w.j a va 2 s .c o m List<Interval> missingIntervals = new ArrayList<>(); DateTime lastEndDate = from; for (ProgrammeDetail program : channelListings.getPrograms(channelId)) { DateTime startDate = program.getStartDate(); if (startDate.isAfter(lastEndDate)) { missingIntervals.add(new Interval(lastEndDate, startDate)); } lastEndDate = program.getEndDate(); } if (lastEndDate.isBefore(to)) { missingIntervals.add(new Interval(lastEndDate, to)); } return missingIntervals; }
From source file:beans.utilidades.MetodosGenerales.java
public boolean fechaDentroDeRangoMas1Dia(Date inicioRango, Date finRango, Date fecBuscada) { //determinar si una fecha esta dentro de un rango; true = fecha en el rango //se suma 1 dia a la fecha final para que incluya el ultimo dia Interval interval = new Interval(new DateTime(inicioRango), new DateTime(finRango).plusDays(1)); return interval.contains(new DateTime(fecBuscada)); }
From source file:beans.utilidades.MetodosGenerales.java
private boolean fechaDentroDeRango(Date inicioRango, Date finRango, Date fecBuscada) { //determinar si una fecha esta dentro de un rango; true = fecha en el rango //no es necesario aumentar el dia final por que se evaluan ambos limites de ambos rangos Interval interval = new Interval(new DateTime(inicioRango), new DateTime(finRango)); return interval.contains(new DateTime(fecBuscada)); }
From source file:BillionGraves.BillionGravesController.java
/** * * @param event/*from w ww .j a v a2s .c om*/ * @throws SQLException */ @FXML public void btnFileIngest(ActionEvent event) throws SQLException { long startTime = System.currentTimeMillis(); //Truncate table is checkbox is selected if (chkBoxTruncate.isSelected() == true) { consoleItems.add("Truncating Load Table"); lstConsole.setItems(consoleItems); } PPOFNLDataWriter truncateTable = new PPOFNLDataWriter(chkBoxTruncate.isSelected()); System.out.println("Ingesting records"); consoleItems.add("Ingesting records"); lstConsole.setItems(consoleItems); //Start the data ingest for (int i = 0; i < (lstViewFiles.getItems().size()); i++) { //loop to process each selected file********* String hashKey = lstViewFiles.getItems().get(i).toString(); selectFilePath = namePath.get(hashKey); String ingestTimeStamp = MiscUtilities.getTimeStamp();//set timestamp for record group field System.out.println(" --Ingesting " + selectFilePath); consoleItems.add(" --Ingesting " + selectFilePath); lstConsole.setItems(consoleItems); //get all the data one row at a time and treat try { dataReader = new TextFileReader(selectFilePath, currentLine, ingestTimeStamp); } catch (IOException ex) { Logger.getLogger(BillionGravesController.class.getName()).log(Level.SEVERE, null, ex); } } PPOFNLDataWriter getGrossRecordCount = new PPOFNLDataWriter("GROSS"); Map<String, Integer> grossCountMap = getGrossRecordCount.grossData; consoleItems.add("Removing Duplicate Records"); lstConsole.setItems(consoleItems); PPOFNLDataWriter removeDupes = new PPOFNLDataWriter();//removes dupes and embedded characters from load table. consoleItems.add("Assigning Unique Identifiers and Creating Sort Keys"); lstConsole.setItems(consoleItems); PPOFNLDataWriter assignUI = new PPOFNLDataWriter(chkBoxUI.isSelected(), "");//Not ready to use. Date endDate = new Date(); PPOFNLDataWriter getNetRecordCount = new PPOFNLDataWriter("NET"); Map<String, Integer> netCountMap = getNetRecordCount.netData; PPOFNLDataWriter writeLog = new PPOFNLDataWriter(grossCountMap, netCountMap, fileGroupIngestTimestamp); long endTime = System.currentTimeMillis(); Interval interval = new Interval(startTime, endTime); Period period = interval.toPeriod(); consoleItems.add("Total elaped time = " + StringUtils.leftPad(String.valueOf(period.getHours()), 2, "0") + ":" + StringUtils.leftPad(String.valueOf(period.getMinutes()), 2, "0") + ":" + StringUtils.leftPad(String.valueOf(period.getSeconds()), 2, "0")); lstConsole.setItems(consoleItems); System.out.println("Total elaped time = " + StringUtils.leftPad(String.valueOf(period.getHours()), 2, "0") + ":" + StringUtils.leftPad(String.valueOf(period.getMinutes()), 2, "0") + ":" + StringUtils.leftPad(String.valueOf(period.getSeconds()), 2, "0")); }
From source file:br.inf.ufes.lar.thtbot.utils.TimeUtil.java
License:Open Source License
/** * Get the number of days elapsed between two Dates. * * @param startDate Start Date.//from w ww .j a v a2s. c om * @param endDate End Date. * @return Number of days elapsed between two Dates. * @see Date * @since 1.0 */ public static int getDaysElapsed(Date startDate, Date endDate) { Interval interval = new Interval(startDate.getTime(), endDate.getTime()); Period period = interval.toPeriod(); return period.getDays(); }
From source file:br.inf.ufes.lar.thtbot.utils.TimeUtil.java
License:Open Source License
/** * Get the number of hours elapsed between two Dates. * * @param startDate Start Date./*w w w . j av a 2s .co m*/ * @param endDate End Date. * @return Number of hours elapsed between two Dates. * @see Date * @since 1.0 */ public static int getHoursElapsed(Date startDate, Date endDate) { Interval interval = new Interval(startDate.getTime(), endDate.getTime()); Period period = interval.toPeriod(); return period.getHours(); }