/**
   * Returns all Weight Reading objects that fall within the time range specified (inclusive)
   *
   * @param leftBound The Date object specifying the earliest date boundary
   * @param rightBound The Date object specifying the latest date boundary
   * @param c The application context
   * @note Recreates only the new objects, since Identity Map is no longer applied: the reason for
   *     this is because whenever data is fetched, we know its usage right away and will not need to
   *     keep it in proximity for later usage, but rather direct usage
   * @return The ArrayList of all weighteReading in the database that fall within range
   * @throws MapperException Thrown when there is either a problem with mapping or if the
   *     Persistence layer returns an error
   */
  public static ArrayList<WeightReading> findAllWithinRangeInclusive(
      Date iLeftBound, Date iRightBound, Context iC) throws MapperException {
    try {
      ArrayList<ArrayList<String>> resultTable =
          WeightTDG.selectBetweenDatesInclusive(
              String.valueOf(iLeftBound.getTime()), String.valueOf(iRightBound.getTime()), iC);
      ArrayList<WeightReading> resultReadings = new ArrayList<WeightReading>(resultTable.size());
      for (int i = 0; i < resultTable.size(); ++i) {
        ArrayList<String> values = resultTable.get(i);
        WeightReading r;
        Long id = Long.valueOf(values.get(0));

        Date date = new Date(Long.valueOf(values.get(1)));
        /** Converts from Unix time to Java Date */
        int sourceInt = Integer.valueOf(values.get(2));
        ReadingSource source = sourceFromInt(sourceInt);
        float weight = Float.valueOf(values.get(3));

        r = new WeightReading(id, date, source, weight);

        resultReadings.add(r);
      }
      return resultReadings;
    } catch (PersistenceException iE) {
      throw new MapperException(
          "The Mapper failed to obtain the Weight Readings from the persistence layer. The TDG returned the following error: "
              + iE.getMessage());
    } catch (Exception iE) {
      throw new MapperException(
          "The mapper failed to complete an operation for the following unforeseen reason: "
              + iE.getMessage());
    }
  }
  /**
   * Compare based on start date.
   *
   * @param aAppt1 appt 1
   * @param aAppt2 appt 2
   * @return an int indicating the result of the comparison
   */
  public int compare(Object aAppt1, Object aAppt2) {
    // Parameter are of type Object, so we have to downcast it
    Date date1 = ((Appt) aAppt1).getStartDate();
    Date date2 = ((Appt) aAppt2).getStartDate();

    return date2.compareTo(date1);
  }
  public static Timestamp getTimeStampFromString(String userTime) throws ParseException {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = dateFormat.parse(userTime);
    Timestamp timestamp = new Timestamp(date.getTime());

    return timestamp;
  }
Exemple #4
0
 /** @tests java.util.Date#hashCode() */
 public void test_hashCode() {
   // Test for method int java.util.Date.hashCode()
   Date d1 = new Date(0);
   Date d2 = new Date(1900000);
   assertEquals("Returned incorrect hash", 1900000, d2.hashCode());
   assertEquals("Returned incorrect hash", 0, d1.hashCode());
 }
Exemple #5
0
 /** @tests java.util.Date#clone() */
 public void test_clone() {
   // Test for method java.lang.Object java.util.Date.clone()
   Date d1 = new Date(100000);
   Date d2 = (Date) d1.clone();
   assertTrue("Cloning date results in same reference--new date is equivalent", d1 != d2);
   assertTrue("Cloning date results unequal date", d1.equals(d2));
 }
  @Override
  public CharSequence getDisplayContents() {

    CalendarParsedResult calResult = (CalendarParsedResult) getResult();
    StringBuilder result = new StringBuilder(100);

    ParsedResult.maybeAppend(calResult.getSummary(), result);

    Date start = calResult.getStart();
    ParsedResult.maybeAppend(format(calResult.isStartAllDay(), start), result);

    Date end = calResult.getEnd();
    if (end != null) {
      if (calResult.isEndAllDay() && !start.equals(end)) {
        // Show only year/month/day
        // if it's all-day and this is the end date, it's exclusive, so show the user
        // that it ends on the day before to make more intuitive sense.
        // But don't do it if the event already (incorrectly?) specifies the same start/end
        end = new Date(end.getTime() - 24 * 60 * 60 * 1000);
      }
      ParsedResult.maybeAppend(format(calResult.isEndAllDay(), end), result);
    }

    ParsedResult.maybeAppend(calResult.getLocation(), result);
    ParsedResult.maybeAppend(calResult.getOrganizer(), result);
    ParsedResult.maybeAppend(calResult.getAttendees(), result);
    ParsedResult.maybeAppend(calResult.getDescription(), result);
    return result.toString();
  }
  public Date transformarJulianaAGregoriadeLong(Long valor) {
    String j = valor.toString();
    Date date = new Date();
    String primerValor = "";
    if (j.length() == 5) {
      try {
        date = new SimpleDateFormat("yyD").parse(j);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      primerValor = j.substring(0, 1);
      if (primerValor.equals("1")) {
        String anno = j.substring(1, 3);
        date.setYear(Integer.valueOf("20" + anno) - 1900);
        String s = j.substring(3);
        Date fecha = new Date();
        try {
          fecha = new SimpleDateFormat("D").parse(s);
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        fecha.setYear(date.getYear());
        return fecha;
      }
    }

    return date;
  }
  @Test
  public void testAddAndGetApproval() {
    String userName = "******";
    String clientId = "client";
    String scope = "uaa.user";
    long expiresIn = 1000l;
    Date lastUpdatedAt = new Date();
    ApprovalStatus status = APPROVED;

    Date expiresAt = new Timestamp(new Date().getTime() + expiresIn);
    Approval newApproval =
        new Approval()
            .setUserId(userName)
            .setClientId(clientId)
            .setScope(scope)
            .setExpiresAt(expiresAt)
            .setStatus(status)
            .setLastUpdatedAt(lastUpdatedAt);
    dao.addApproval(newApproval);
    List<Approval> approvals = dao.getApprovals(userName, clientId);

    assertEquals(clientId, approvals.get(0).getClientId());
    assertEquals(userName, approvals.get(0).getUserId());
    assertEquals(
        Math.round(expiresAt.getTime() / 1000),
        Math.round(approvals.get(0).getExpiresAt().getTime() / 1000));
    assertEquals(
        Math.round(lastUpdatedAt.getTime() / 1000),
        Math.round(approvals.get(0).getLastUpdatedAt().getTime() / 1000));
    assertEquals(scope, approvals.get(0).getScope());
    assertEquals(status, approvals.get(0).getStatus());
  }
 public static String millisecondsToHumanDateWithSeconds(long milliseconds) {
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   sdf.setTimeZone(CURRENT_TIME_ZONE);
   Date t = new Date();
   t.setTime(milliseconds);
   return sdf.format(t);
 }
 public static String format(long milliseconds, String format) {
   SimpleDateFormat sdf = new SimpleDateFormat(format);
   sdf.setTimeZone(CURRENT_TIME_ZONE);
   Date t = new Date();
   t.setTime(milliseconds);
   return sdf.format(t);
 }
  protected void verifyCreateDate(JournalArticleResource articleResource) {
    List<JournalArticle> articles =
        JournalArticleLocalServiceUtil.getArticles(
            articleResource.getGroupId(),
            articleResource.getArticleId(),
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            new ArticleVersionComparator(true));

    if (articles.size() <= 1) {
      return;
    }

    JournalArticle firstArticle = articles.get(0);

    Date createDate = firstArticle.getCreateDate();

    for (JournalArticle article : articles) {
      if (!createDate.equals(article.getCreateDate())) {
        article.setCreateDate(createDate);

        JournalArticleLocalServiceUtil.updateJournalArticle(article);
      }
    }
  }
  @Test
  public void getProductStatusSuccessfully() throws Exception {
    Date date = new Date();
    String dateInString = Long.toString(date.getTime());
    AggregationMappingEntry entry =
        new AggregationMappingEntry("10", date, date, Status.InProgress);
    AggregationMappingEntry entry1 =
        new AggregationMappingEntry("11", date, date, Status.InProgress);

    List<AggregationMappingEntry> entries = new ArrayList<AggregationMappingEntry>();
    entries.add(entry);
    entries.add(entry1);

    List<Long> epids = new ArrayList<Long>();
    epids.add(10L);
    epids.add(11L);

    when(productService.findProducts(epids)).thenReturn(entries);

    mockMvc
        .perform(get("/status/10,11"))
        .andDo(print())
        .andExpect(jsonPath("$.products[*].epid", hasItems(is("10"), is("11"))))
        .andExpect(
            jsonPath("$.products[*].createdDate", hasItems(is(entry.getCreationDate().getTime()))))
        /*  .andExpect(jsonPath("$.links[*].rel",
        hasItems(endsWith("self"), endsWith("10"))))*/
        .andExpect(status().isOk());
  }
Exemple #13
0
  public static CoveringInfo getWeeklyCoveringInfo(Date from, Date to) {
    int dayDiff = 0;
    Date tmpFrom = from;
    while (tmpFrom.before(to)) {
      tmpFrom = DateUtils.addDays(tmpFrom, 1);
      dayDiff++;
    }

    if (dayDiff < 7) {
      return new CoveringInfo(0, false);
    }

    Calendar cal = Calendar.getInstance();
    cal.setTime(from);
    int fromWeek = cal.get(Calendar.WEEK_OF_YEAR);
    int fromDay = cal.get(Calendar.DAY_OF_WEEK);
    int fromYear = cal.get(YEAR);

    cal.clear();
    cal.set(YEAR, fromYear);
    cal.set(Calendar.WEEK_OF_YEAR, fromWeek);
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    int maxDayInWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK);
    Date fromWeekStartDate = cal.getTime();
    boolean coverable = dayDiff % 7 == 0;
    if (fromWeekStartDate.before(from)) {
      // Count from the start of next week
      dayDiff -= (maxDayInWeek - (fromDay - Calendar.SUNDAY));
      coverable = false;
    }

    return new CoveringInfo(dayDiff / 7, coverable);
  }
  private void dumpDocument(int docNum, Document doc) throws IOException {

    outputLn();
    outputLn("Document " + docNum);

    if (doc == null) {
      outputLn("    deleted");
      return;
    }

    // note: only stored fields will be returned
    for (Fieldable field : doc.getFields()) {
      String fieldName = field.name();

      boolean isDate = "l.date".equals(fieldName);

      outputLn("    Field [" + fieldName + "]: " + field.toString());
      String[] values = doc.getValues(fieldName);
      if (values != null) {
        int i = 0;
        for (String value : values) {
          output("         " + "(" + i++ + ") " + value);
          if (isDate) {
            try {
              Date date = DateTools.stringToDate(value);
              output(" (" + date.toString() + " (" + date.getTime() + "))");
            } catch (java.text.ParseException e) {
              assert false;
            }
          }
          outputLn();
        }
      }
    }
  }
Exemple #15
0
  @Test
  public void testCronTriggerJob() throws Exception {
    SessionConfiguration config = new SessionConfiguration();
    config.setClockType(ClockType.PSEUDO_CLOCK);
    PseudoClockScheduler timeService =
        (PseudoClockScheduler) TimerServiceFactory.getTimerService(config);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    Date date = df.parse("2009-01-01T00:00:00.000-0000");

    timeService.advanceTime(date.getTime(), TimeUnit.MILLISECONDS);

    CronTrigger trigger =
        new CronTrigger(date.getTime(), null, null, -1, "15 * * * * ?", null, null);

    HelloWorldJobContext ctx = new HelloWorldJobContext("hello world", timeService);
    timeService.scheduleJob(new HelloWorldJob(), ctx, trigger);

    assertEquals(0, ctx.getList().size());

    timeService.advanceTime(10, TimeUnit.SECONDS);
    assertEquals(0, ctx.getList().size());

    timeService.advanceTime(10, TimeUnit.SECONDS);
    assertEquals(1, ctx.getList().size());

    timeService.advanceTime(30, TimeUnit.SECONDS);
    assertEquals(1, ctx.getList().size());

    timeService.advanceTime(30, TimeUnit.SECONDS);
    assertEquals(2, ctx.getList().size());
  }
  public void messageReceived(int to, Message message) {
    Date date = Calendar.getInstance().getTime();

    if (message instanceof RadioSignalResultsMsg) {
      RadioSignalResultsMsg resultMsg = (RadioSignalResultsMsg) message;
      log(
          date
              + "\t"
              + date.getTime()
              + "\t"
              + "RADIO15.4_RESULT_MSG"
              + "\t"
              + resultMsg.get_idReceiver()
              + "\t"
              + resultMsg.get_idSender()
              + "\t"
              + resultMsg.get_seqno()
              + "\t"
              + resultMsg.get_rssi()
              + "\t"
              + resultMsg.get_lqi()
              + "\t"
              + resultMsg.get_timestamp());
    } else {
      log(date + "\t" + date.getTime() + "\t UNKNOWN_MSG" + "\t" + message.toString());
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public <R extends HttpRequest> R bindToRequest(R request, Object input) {
    Builder<?> builder = request.toBuilder();
    Payload payload = Payload.class.cast(input);

    if (payload.getContentMetadata().getContentType() == null) {
      payload.getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
    }

    Long contentLength = payload.getContentMetadata().getContentLength();
    if (contentLength != null && contentLength >= 0) {
      checkArgument(
          contentLength <= 5l * 1024 * 1024 * 1024,
          "maximum size for put object is 5GB, %s",
          contentLength);
    } else {
      builder.replaceHeader(TRANSFER_ENCODING, "chunked").build();
    }

    byte[] md5 = payload.getContentMetadata().getContentMD5();
    if (md5 != null) {
      // Swift will validate the md5, if placed as an ETag header
      builder.replaceHeader(ETAG, base16().lowerCase().encode(md5));
    }

    Date expires = payload.getContentMetadata().getExpires();
    if (expires != null) {
      builder
          .replaceHeader(
              OBJECT_DELETE_AT, String.valueOf(MILLISECONDS.toSeconds(expires.getTime())))
          .build();
    }
    return (R) builder.payload(payload).build();
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   CatalogCategoryMaster other = (CatalogCategoryMaster) obj;
   if (businessName == null) {
     if (other.businessName != null) return false;
   } else if (!businessName.equals(other.businessName)) return false;
   if (code == null) {
     if (other.code != null) return false;
   } else if (!code.equals(other.code)) return false;
   if (dateCreate == null) {
     if (other.dateCreate != null) return false;
   } else if (!dateCreate.equals(other.dateCreate)) return false;
   if (dateUpdate == null) {
     if (other.dateUpdate != null) return false;
   } else if (!dateUpdate.equals(other.dateUpdate)) return false;
   if (defaultParentCatalogCategory == null) {
     if (other.defaultParentCatalogCategory != null) return false;
   } else if (!defaultParentCatalogCategory.equals(other.defaultParentCatalogCategory))
     return false;
   if (description == null) {
     if (other.description != null) return false;
   } else if (!description.equals(other.description)) return false;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (isDefault != other.isDefault) return false;
   if (version != other.version) return false;
   return true;
 }
  public static int driver(
      String inputMaf, String outputMaf, boolean useCache, boolean sort, boolean addMissing) {
    Date start = new Date();
    int oncoResult = 0;

    Oncotator tool = new Oncotator(useCache);
    tool.setSortColumns(sort);
    tool.setAddMissingCols(addMissing);

    try {
      oncoResult = tool.oncotateMaf(new File(inputMaf), new File(outputMaf));
    } catch (IOException e) {
      System.out.println("IO error occurred: " + e.getMessage());
      e.printStackTrace();
    } catch (OncotatorServiceException e) {
      System.out.println("Service error occurred: " + e.getMessage());
      e.printStackTrace();
    } finally {
      Date end = new Date();
      double timeElapsed = (end.getTime() - start.getTime()) / 1000.0;

      System.out.println("Total number of records processed: " + tool.getNumRecordsProcessed());

      if (tool.getBuildNumErrors() > 0) {
        System.out.println(
            "Number of records skipped due to incompatible build no: " + tool.getBuildNumErrors());
      }

      System.out.println("Total time: " + timeElapsed + " seconds.");
    }

    return oncoResult;
  }
 public static String agregarGasto(
     int tipo, Date fecha, int tipoDoc, String numDoc, String descripcion, String monto) {
   float montoTotal;
   int numDocumento;
   try {
     montoTotal = Float.parseFloat(monto);
   } catch (Exception e) {
     return "Ingrese un monto valido";
   }
   try {
     numDocumento = Integer.parseInt(numDoc);
   } catch (Exception e) {
     return "El numero de documento solo puede contener numeros";
   }
   if (ValidacionGeneral.precioValido(montoTotal)) {
     Gastos g = new Gastos(1, fecha.getDay(), fecha.getMonth(), fecha.getYear(), montoTotal);
     g.setGasNumDoc(numDocumento);
     g.setTipDocCod(new TipoDocumento(tipoDoc));
     g.setEmpDni(new Empleado(Integer.parseInt(ManejoSesion.getDNI())));
     g.setProvRuc(new Proveedor("00000000001"));
     g.setTipGasCod(new TipoGasto(tipo));
     new GestionarGastosImplementacion().agregarGasto(g);
     return "CORRECTO";
   } else {
     return "Ingrese un monto valido";
   }
 }
  protected URL createSnapshot(final String foreignSource) throws MalformedURLException {
    System.err.println("--- creating snapshot for " + foreignSource + " ---");
    Requisition pending = m_pending.getRequisition(foreignSource);
    Requisition deployed = m_active.getRequisition(foreignSource);

    final Date deployedDate = deployed == null ? null : deployed.getDate();
    final Date pendingDate = pending == null ? null : pending.getDate();

    if (deployedDate == null)
      return RequisitionFileUtils.createSnapshot(m_pending, foreignSource, pending.getDate())
          .toURI()
          .toURL();
    if (pendingDate == null) return m_active.getRequisitionURL(foreignSource);

    final URL url;
    if (deployedDate.before(pendingDate)) {
      url =
          RequisitionFileUtils.createSnapshot(m_pending, foreignSource, pendingDate)
              .toURI()
              .toURL();
    } else {
      url = m_active.getRequisitionURL(foreignSource);
    }

    System.err.println("deployedDate = " + deployedDate);
    System.err.println("pendingDate  = " + pendingDate);
    System.err.println("url          = " + url);

    return url;
  }
 public static String agregarGasto(
     Date fecha,
     int tipoDoc,
     String numDoc,
     String descripcion,
     float montoTotal,
     ArrayList<InsumoAlmacen> insumos,
     String ruc) {
   int numDocumento;
   try {
     numDocumento = Integer.parseInt(numDoc);
   } catch (Exception e) {
     return "Error: El numero de documento solo puede contener numeros";
   }
   Gastos g = new Gastos(0, fecha.getDay(), fecha.getMonth(), fecha.getYear(), montoTotal);
   g.setGasDes("Pago por insumos");
   g.setGasNumDoc(numDocumento);
   g.setGasNBol(numDocumento);
   g.setTipDocCod(new TipoDocumento(tipoDoc));
   g.setEmpDni(new Empleado(Integer.parseInt(ManejoSesion.getDNI())));
   g.setProvRuc(new Proveedor(ruc));
   g.setTipGasCod(new TipoGasto(1));
   if (new GestionarGastosImplementacion().agregarGasto(g)) {
     for (InsumoAlmacen ins : insumos) {
       IngresoKardexControlador.agregarIngresoKardex(
           g.getGasCod(), ins.getCodInsumo(), ins.getCantidad(), ins.getPrecio());
     }
     return "CORRECTO";
   } else {
     return "No se pudo agregar el gasto";
   }
 }
Exemple #23
0
 /** @tests java.util.Date#before(java.util.Date) */
 public void test_beforeLjava_util_Date() {
   // Test for method boolean java.util.Date.before(java.util.Date)
   Date d1 = new Date(0);
   Date d2 = new Date(1900000);
   assertTrue("Older was returned as newer", !d2.before(d1));
   assertTrue("Newer was returned as older", d1.before(d2));
 }
Exemple #24
0
 public Item(
     String source,
     String link,
     String title,
     String description,
     Date datePublication,
     List enclosure) {
   try {
     this.uri = link;
     values = new ArrayList<Prop>();
     values.add(new Prop(RSS.link, link, true, false));
     values.add(new Prop(RSS.title, title));
     values.add(new Prop(RSS.description, Jsoup.parse(description).text()));
     if (datePublication != null) {
       values.add(new Prop(RSS.getURI() + "pubDate", datePublication.toString()));
       values.add(
           new Prop(RSS.getURI() + "pubDateTime", Long.toString(datePublication.getTime())));
     }
     for (Object o : enclosure) {
       SyndEnclosureImpl e = (SyndEnclosureImpl) o;
       values.add(new Prop(RSS.image, e.getUrl(), true, false));
     }
     values.add(new Prop("http://purl.org/rss/1.0/source", source, false, false));
   } catch (NullPointerException e) {
     logger.error(e);
   }
 }
Exemple #25
0
 /** @tests java.util.Date#getTime() */
 public void test_getTime() {
   // Test for method long java.util.Date.getTime()
   Date d1 = new Date(0);
   Date d2 = new Date(1900000);
   assertEquals("Returned incorrect time", 1900000, d2.getTime());
   assertEquals("Returned incorrect time", 0, d1.getTime());
 }
Exemple #26
0
  /**
   * Calculate the next alarm time for overdue reminders.
   *
   * <p>We schedule an alarm for after the due date (which could be in the past), with the exception
   * that if a reminder was recently issued, we move the alarm time to the near future.
   *
   * @param task
   * @return
   */
  private long calculateNextOverdueReminder(Task task) {
    // Uses getNowValue() instead of DateUtilities.now()
    if (task.hasDueDate() && task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE)) {
      Date due = new Date(task.getValue(Task.DUE_DATE));
      if (!task.hasDueTime()) {
        due.setHours(23);
        due.setMinutes(59);
        due.setSeconds(59);
      }
      long dueDateForOverdue = due.getTime();
      long lastReminder = task.getValue(Task.REMINDER_LAST);

      if (dueDateForOverdue > getNowValue()) {
        return dueDateForOverdue
            + (long) ((0.5f + 2f * random.nextFloat()) * DateUtilities.ONE_HOUR);
      }

      if (lastReminder < dueDateForOverdue) {
        return getNowValue();
      }

      if (getNowValue() - lastReminder < 6 * DateUtilities.ONE_HOUR) {
        return getNowValue()
            + (long)
                ((2.0f + task.getValue(Task.IMPORTANCE) + 6f * random.nextFloat())
                    * DateUtilities.ONE_HOUR);
      }

      return getNowValue();
    }
    return NO_ALARM;
  }
Exemple #27
0
 /** @tests java.util.Date#UTC(int, int, int, int, int, int) */
 public void test_UTCIIIIII() {
   // Test for method long java.util.Date.UTC(int, int, int, int, int, int)
   assertTrue("Returned incorrect UTC value for epoch", Date.UTC(70, 0, 1, 0, 0, 0) == (long) 0);
   assertTrue(
       "Returned incorrect UTC value for epoch +1yr",
       Date.UTC(71, 0, 1, 0, 0, 0) == (long) 365 * 24 * 60 * 60 * 1000);
 }
  @SuppressWarnings("deprecation")
  private void createAverages(Date start) {
    if (start.getMinutes() != 30 || start.getSeconds() != 0) {
      // we want to obtain estimates for full hours, i.e. 4:00 or 5:00
      // by calculating averages for 3:30-4:29:59 and 4:30-5:29:59
      throw new RuntimeException("Must start with hh:30:00");
    }

    final int HOURS = 25; // we want to have vehicles for full 24 hours, e.g. 4am to 4am next day

    long startTime = start.getTime() / 1000; // in seconds
    long endTime = startTime + HOURS * 3600; // in seconds

    taxisOverTimeHourlyAverage = new double[HOURS];
    int sum = 0;
    int hour = 0;
    int n = 0;

    for (long t = startTime; t < endTime; t++) {
      if (this.taxisOverTime.containsKey(new Date(t * 1000))) {
        sum += this.taxisOverTime.get(new Date(t * 1000)); // seconds -> milliseconds
        n++;
      }
      if (t % 3600 == 1799) { // t == hh:29:59
        taxisOverTimeHourlyAverage[hour] += (double) sum / n;
        sum = 0;
        hour++;
        n = 0;
      }
    }

    for (int i = 0; i < HOURS; i++) {
      System.out.println(i + " : " + taxisOverTimeHourlyAverage[i]);
    }
  }
 public static Calendar getCalendarFromString(String userTime) throws ParseException {
   DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Date date = dateFormat.parse(userTime);
   Calendar cal = Calendar.getInstance();
   cal.setTimeInMillis(date.getTime());
   return cal;
 }
 // See one project
 @RequestMapping(value = "viewproject", method = RequestMethod.GET)
 public ModelAndView viewproject(Integer id) throws Exception {
   ModelAndView mav = new ModelAndView();
   ProjectWrapper pw = projectDao.getProjectWrapperById(id);
   mav.addObject("pw", pw);
   Date now = new Date();
   DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   if (!pw.getProject().getEndDate().trim().equals("")) {
     boolean expired = now.after(df.parse(pw.getProject().getEndDate()));
     mav.addObject("expired", expired);
   }
   for (RPLink r : pw.getRpLinks()) {
     if (!r.getResearcher().getEndDate().trim().equals("")) {
       if (now.after(df.parse(r.getResearcher().getEndDate()))) {
         r.getResearcher().setFullName(r.getResearcher().getFullName() + " (expired)");
       }
     }
   }
   for (APLink a : pw.getApLinks()) {
     if (a.getAdviser().getEndDate() != null && !a.getAdviser().getEndDate().trim().equals("")) {
       if (now.after(df.parse(a.getAdviser().getEndDate()))) {
         a.getAdviser().setFullName(a.getAdviser().getFullName() + " (expired)");
       }
     }
   }
   mav.addObject("jobauditBaseProjectUrl", this.jobauditBaseProjectUrl);
   return mav;
 }