/** programId is ignored for now as oscar doesn't support it yet. */
  public List<Prevention> getPreventionsByProgramProviderDemographicDate(
      LoggedInInfo loggedInInfo,
      Integer programId,
      String providerNo,
      Integer demographicId,
      Calendar updatedAfterThisDateExclusive,
      int itemsToReturn) {
    List<Prevention> results =
        preventionDao.findByProviderDemographicLastUpdateDate(
            providerNo, demographicId, updatedAfterThisDateExclusive.getTime(), itemsToReturn);

    LogAction.addLogSynchronous(
        loggedInInfo,
        "PreventionManager.getUpdatedAfterDate",
        "programId="
            + programId
            + ", providerNo="
            + providerNo
            + ", demographicId="
            + demographicId
            + ", updatedAfterThisDateExclusive="
            + updatedAfterThisDateExclusive.getTime());

    return (results);
  }
  public void testExpireBuffer() throws NoSuchAlgorithmException, NoSuchPaddingException {
    DefaultTokenCacheStore store = (DefaultTokenCacheStore) setupItems();

    ArrayList<TokenCacheItem> tokens = store.getTokensForUser("userid1");
    Calendar expireTime = Calendar.getInstance();
    Logger.d(TAG, "Time now: " + expireTime.getTime());
    expireTime.add(Calendar.SECOND, 240);
    Logger.d(TAG, "Time modified: " + expireTime.getTime());

    // Sets token to expire if less than this buffer
    AuthenticationSettings.INSTANCE.setExpirationBuffer(300);
    for (TokenCacheItem item : tokens) {
      item.setExpiresOn(expireTime.getTime());
      assertTrue("Should say expired", TokenCacheItem.isTokenExpired(item.getExpiresOn()));
    }

    // Set expire time ahead of buffer 240 +100 secs more than 300secs
    // buffer
    expireTime.add(Calendar.SECOND, 100);
    for (TokenCacheItem item : tokens) {
      item.setExpiresOn(expireTime.getTime());
      assertFalse(
          "Should not say expired since time is more than buffer",
          TokenCacheItem.isTokenExpired(item.getExpiresOn()));
    }
  }
 public Offer createOffer(
     String offerName,
     OfferType offerType,
     OfferDiscountType discountType,
     double value,
     String customerRule,
     String orderRule,
     boolean stackable,
     boolean combinable,
     int priority) {
   Offer offer = offerDao.create();
   offer.setName(offerName);
   offer.setStartDate(SystemTime.asDate());
   Calendar calendar = Calendar.getInstance();
   calendar.add(Calendar.DATE, -1);
   offer.setStartDate(calendar.getTime());
   calendar.add(Calendar.DATE, 2);
   offer.setEndDate(calendar.getTime());
   offer.setType(offerType);
   offer.setDiscountType(discountType);
   offer.setValue(BigDecimal.valueOf(value));
   offer.setDeliveryType(OfferDeliveryType.CODE);
   offer.setStackable(stackable);
   offer.setAppliesToOrderRules(orderRule);
   offer.setAppliesToCustomerRules(customerRule);
   offer.setCombinableWithOtherOffers(combinable);
   offer.setPriority(priority);
   offer = offerService.save(offer);
   offer.setMaxUses(50);
   return offer;
 }
Exemple #4
0
  private long
      TimeDifference() { // need to check the alaram time and the triggring action time around 12

    Calendar cal = Calendar.getInstance();
    Log.d("settings.java ", " time before setting :" + cal.getTime());
    Log.d("settings.java ", " calendertime in millisec: " + cal.getTimeInMillis());
    Log.d("settings.java ", " system time in millisec :" + System.currentTimeMillis());

    // cal.setTime();

    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    // cal.set(Calendar.HOUR, 23);
    cal.set(Calendar.MINUTE, 0);
    cal.add(Calendar.DAY_OF_MONTH, 1);

    Log.d("settings.java", " time After setting day+1 and 00 hours :" + cal.getTime());

    Log.d("settings.java", " set time in millis :" + cal.getTimeInMillis());
    Log.d(
        "settings.java",
        " time of the system in millis" + Calendar.getInstance().getTimeInMillis());

    long timediff = cal.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); // +1000;

    Log.d(
        "settings.java",
        " current time: "
            + Calendar.getInstance()
            + " setted time in alaram should be 23.59.59 but is : "
            + cal.getTime()
            + "time diff in millisec :"
            + timediff);
    return timediff;
  }
  @Test
  public void checkBooking() throws CabNotAvailableException {
    Cab one = new Cab("DL01HB001", 100020);
    Cab two = new Cab("DL01HB002", 100040);
    Cab three = new Cab("DL01HB003", 100060);
    Cab four = new Cab("DL01HB004", 100080);

    ICabBookingSystem system = new CabBookingSystemImpl();
    system.addCab(one);
    system.addCab(two);
    system.addCab(three);
    system.addCab(four);

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, 10);
    String cab = system.requestForCab(new CabRequest("BR001", 100025, 100056, cal.getTime()));
    Assert.assertEquals(cab, "DL01HB001");

    cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, 11);
    cab = system.requestForCab(new CabRequest("BR002", 100056, 100022, cal.getTime()));
    Assert.assertEquals(cab, "DL01HB003");

    cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, 15);
    cab = system.requestForCab(new CabRequest("BR003", 100020, 100075, cal.getTime()));
    Assert.assertEquals(cab, "DL01HB003");

    cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, 15);
    cab = system.requestForCab(new CabRequest("BR004", 100040, 100056, cal.getTime()));
    Assert.assertEquals(cab, "DL01HB002");
  }
  private static Date[] parseTimeDuration(final String[] period) throws ParseException {
    Date[] range = null;

    if (period.length == 2 || period.length == 3) {
      Date begin = null;
      Date end = null;

      // Check first to see if we have any duration value within TIME parameter
      if (period[0].toUpperCase().startsWith("P") || period[1].toUpperCase().startsWith("P")) {
        long durationOffset = Long.MIN_VALUE;

        // Attempt to parse a time or duration from the first portion of the
        if (period[0].toUpperCase().startsWith("P")) {
          durationOffset = parsePeriod(period[0]);
        } else {
          begin = beginning(getFuzzyDate(period[0]));
        }

        if (period[1].toUpperCase().startsWith("P")
            && !period[1].toUpperCase().startsWith("PRESENT")) {
          // Invalid time period of the format:
          // DURATION/DURATION[/PERIOD]
          if (durationOffset != Long.MIN_VALUE) {
            throw new ParseException(
                "Invalid time period containing duration with no paired time value: "
                    + Arrays.toString(period),
                0);
          }
          // Time period of the format:
          // DURATION/TIME[/PERIOD]
          else {
            durationOffset = parsePeriod(period[1]);
            final Calendar calendar = new GregorianCalendar();
            calendar.setTimeInMillis(begin.getTime() + durationOffset);
            end = calendar.getTime();
          }
        }
        // Time period of the format:
        // TIME/DURATION[/PERIOD]
        else {
          end = end(getFuzzyDate(period[1]));
          final Calendar calendar = new GregorianCalendar();
          calendar.setTimeInMillis(end.getTime() - durationOffset);
          begin = calendar.getTime();
        }
      }
      // Time period of the format:
      // TIME/TIME[/PERIOD]
      else {
        begin = beginning(getFuzzyDate(period[0]));
        end = end(getFuzzyDate(period[1]));
      }

      range = new Date[2];
      range[0] = begin;
      range[1] = end;
    }

    return range;
  }
Exemple #7
0
  /** Returns a new Calendar object which is between start and end */
  public static Calendar rand(Calendar start, Calendar end) {
    if (start.after(end)) {
      Calendar temp = start;
      start = end;
      end = temp;
    }
    long diff = end.getTime().getTime() - start.getTime().getTime();
    long daysDiff = diff / (1000 * 60 * 60 * 24);

    int delta = rand(0, (int) daysDiff);

    Calendar newCal = Calendar.getInstance();
    newCal.setTime(start.getTime());
    newCal.setTimeZone(start.getTimeZone());

    newCal.add(Calendar.DAY_OF_MONTH, delta);
    newCal.add(Calendar.HOUR, rand(0, 23));
    newCal.add(Calendar.MINUTE, rand(0, 59));
    newCal.add(Calendar.SECOND, rand(0, 59));

    // check range cause we might random picked value
    // greater than the range.
    if (newCal.after(end)) {
      newCal.setTime(end.getTime());
      newCal.setTimeZone(end.getTimeZone());
    }
    if (newCal.before(start)) {
      newCal.setTime(start.getTime());
      newCal.setTimeZone(start.getTimeZone());
    }

    return newCal;
  }
 public Object getNextValue() {
   Calendar cal = Calendar.getInstance();
   cal.setTime(value.getTime());
   cal.add(calendarField, 1);
   Date next = cal.getTime();
   return ((end == null) || (end.compareTo(next) >= 0)) ? next : null;
 }
 public Object getPreviousValue() {
   Calendar cal = Calendar.getInstance();
   cal.setTime(value.getTime());
   cal.add(calendarField, -1);
   Date prev = cal.getTime();
   return ((start == null) || (start.compareTo(prev) <= 0)) ? prev : null;
 }
  public void reset() {
    try {
      leaveStartCalendar = Calendar.getInstance();
      leaveStartCalendar.setTime(app.dateFormatDefault.parse(leave.getStartDate()));
      leaveEndCalendar = Calendar.getInstance();
      leaveEndCalendar.setTime(app.dateFormatDefault.parse(leave.getEndDate()));
      tempEndLeaveEndCalendar = null;
      if (Math.abs(leave.getDays() - 0.1) < 0.00001) tvNumDays.setText("AM");
      else if (Math.abs(leave.getDays() - 0.2) < 0.00001) tvNumDays.setText("PM");
      else tvNumDays.setText((int) leave.getDays() + ((leave.getDays() > 1) ? " Days" : " Day"));

      tvDurations.setText(
          app.dateFormatDefault.format(leaveStartCalendar.getTime())
              + ((leave.getDays() > 1)
                  ? " - " + app.dateFormatDefault.format(leaveEndCalendar.getTime())
                  : ""));
      tvRemDays.setText(remBalance + " Days Remaining");

      tempLeaveDuration = leave.getDays();
      tempRemBalance = remBalance;
      adapter.notifyDataSetChanged();
    } catch (Exception e) {
      e.printStackTrace();
      Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  }
Exemple #11
0
 @SuppressWarnings("unchecked")
 @Transactional(readOnly = true)
 public List<RouteEntity> getRoutesByCityIds(
     String cityFrom, String cityTo, Date date, boolean is3days) {
   Query q = null;
   String sql =
       "SELECT r FROM RouteEntity r WHERE isActive = true AND ("
           + "(regFrom = :regFrom AND regTo = :regTo ) "
           + " OR (regFrom = :regFrom AND throughCities LIKE :throughTo) "
           + " OR (throughCities LIKE :throughFrom AND regTo = :regTo ) "
           + " OR (throughCities LIKE :throughFrom AND throughCities LIKE :throughTo ) )"
           + (is3days
               ? " AND (regDate BETWEEN :lowerDate AND :upperDate) "
               : " AND regDate = :date ")
           + " ORDER BY regDate, regTime";
   q = em.createQuery(sql);
   q.setParameter("regFrom", cityFrom);
   q.setParameter("regTo", cityTo);
   if (!is3days) {
     q.setParameter("date", date);
   } else {
     Calendar c = Calendar.getInstance();
     c.setTime(date);
     c.add(Calendar.DATE, -3);
     q.setParameter("lowerDate", c.getTime(), TemporalType.DATE);
     c = Calendar.getInstance();
     c.setTime(date);
     c.add(Calendar.DATE, 3);
     q.setParameter("upperDate", c.getTime(), TemporalType.DATE);
   }
   q.setParameter("throughTo", "%" + cityTo + "%");
   q.setParameter("throughFrom", "%" + cityFrom + "%");
   return (List<RouteEntity>) q.getResultList();
 }
  public void setUpTest() {
    periodService = (PeriodService) getBean(PeriodService.ID);

    periodType = periodService.getPeriodTypeByName(MonthlyPeriodType.NAME);

    Calendar calendar = Calendar.getInstance();

    calendar.clear();

    calendar.set(2000, 0, 1);

    dateA = calendar.getTime();

    calendar.set(2000, 1, 1);

    dateB = calendar.getTime();

    calendar.set(2000, 2, 1);

    dateC = calendar.getTime();

    calendar.set(2000, 3, 1);

    dateD = calendar.getTime();

    batchHandlerFactory = (BatchHandlerFactory) getBean(BatchHandlerFactory.ID);

    batchHandler = batchHandlerFactory.createBatchHandler(PeriodBatchHandler.class);

    batchHandler.init();

    periodA = createPeriod(periodType, dateA, dateB);
    periodB = createPeriod(periodType, dateB, dateC);
    periodC = createPeriod(periodType, dateC, dateD);
  }
 @Cacheable(value = "KLineBuss.querySeriesByCode")
 public Series querySeriesByCode(String code, int month) {
   Futures prod = productBuss.queryFuturesByCode(code);
   if (prod == null) {
     return Series.EMPTY;
   } else {
     List<KLine> kLineList = null;
     if (month < 0) {
       kLineList = this.queryAscByCode(code);
     } else {
       Calendar cal = Calendar.getInstance();
       Date endDt = cal.getTime();
       cal.add(Calendar.MONTH, -month);
       Date startDt = cal.getTime();
       kLineList = kLineRepos.findByCodeAndDtBetweenOrderByDtAsc(code, startDt, endDt);
     }
     List<Price> prices =
         kLineList
             .stream()
             .map(
                 kLine -> {
                   return new Price(kLine.getDt(), kLine.getEndPrice());
                 })
             .collect(Collectors.toList());
     return new Series(prod.getCode(), prod.getName(), prices);
   }
 }
  /* (non-Javadoc)
   * @see com.adibrata.smartdealer.service.othertransactions.OtherReceive#Save(com.adibrata.smartdealer.model.OtherRcvHdr, com.adibrata.smartdealer.model.OtherRcvDtl)
   */
  @SuppressWarnings("unused")
  @Override
  public void Save(String usrupd, OtherRcvHdr otherRcvHdr, List<OtherRcvDtl> lstotherRcvDtl)
      throws Exception {
    // TODO Auto-generated method stub
    session.getTransaction().begin();
    try {
      String transno =
          TransactionNo(
              session,
              TransactionType.otherreceive,
              otherRcvHdr.getPartner().getPartnerCode(),
              otherRcvHdr.getOffice().getId());
      otherRcvHdr.setOtherRcvNo(transno);
      otherRcvHdr.setDtmCrt(dtmupd.getTime());
      otherRcvHdr.setDtmUpd(dtmupd.getTime());
      session.save(otherRcvHdr);

      for (OtherRcvDtl arow : lstotherRcvDtl) {
        OtherRcvDtl otherRcvDtl = new OtherRcvDtl();
        otherRcvDtl.setOtherRcvHdr(otherRcvHdr);
        otherRcvDtl.setDtmCrt(dtmupd.getTime());
        otherRcvDtl.setDtmUpd(dtmupd.getTime());
        session.save(otherRcvDtl);
      }
      session.getTransaction().commit();

    } catch (Exception exp) {
      session.getTransaction().rollback();
      ExceptionEntities lEntExp = new ExceptionEntities();
      lEntExp.setJavaClass(Thread.currentThread().getStackTrace()[1].getClassName());
      lEntExp.setMethodName(Thread.currentThread().getStackTrace()[1].getMethodName());
      ExceptionHelper.WriteException(lEntExp, exp);
    }
  }
Exemple #15
0
  /**
   * desc:获取相距时间time参数为年月日时分秒的时间
   *
   * @param int...time 年月日时分秒顺序输入参数,允许部分参数
   * @return 返回时间 如:DateUtil.getTimeAfterTime(2007,12,26)
   */
  public static Date getTimeAfterTime(int... time) {
    Calendar now = new GregorianCalendar();

    if ((time == null) || (time.length == 0)) {
      return now.getTime();
    }

    int len = time.length;
    int[] times = time;

    for (int i = 0; i < len; i++) {
      switch (i) {
        case 0:
          now.add(Calendar.YEAR, times[i]);
          break;
        case 1:
          now.add(Calendar.MONTH, times[i]);
          break;
        case 2:
          now.add(Calendar.DATE, times[i]);
          break;
        case 3:
          now.add(Calendar.HOUR, times[i]);
          break;
        case 4:
          now.add(Calendar.MINUTE, times[i]);
        case 5:
          now.add(Calendar.SECOND, times[i]);
          break;
      }
    }
    return now.getTime();
  }
  public boolean isCustomHoliday(Calendar date) {
    if (isHolidayWorking) {
      SharedPreferences handle = getApplicationContext().getSharedPreferences("CUSTOM_HOLIDAYS", 0);

      long startL = handle.getLong("START_DATE", 0);
      long endL = handle.getLong("END_DATE", 0);

      if (startL > 0 && endL > 0) {
        Calendar calStart = Calendar.getInstance();
        Calendar calEnd = Calendar.getInstance();

        calStart.setTimeInMillis(startL);
        calEnd.setTimeInMillis(endL);

        int n =
            (int)
                ((calEnd.getTime().getTime() - calStart.getTime().getTime())
                    / (1000 * 60 * 60 * 24));
        for (int i = 0; i <= n; i++) {
          if (date.compareTo(calStart) == 0) {
            Log.i("Holiday", date.getTime().toString());
            return true;
          } else {
            calStart.add(Calendar.DATE, 1);
          }
        }
      }
    }
    return false;
  }
Exemple #17
0
  /**
   * 按周获得某几周周一 00:00:00 到周六 的时间范围
   *
   * <p>它会根据给定的 offL 和 offR 得到一个时间范围
   *
   * <p>对本函数来说 week(-3,-5) 和 week(-5,-3) 是一个意思
   *
   * @param base 基础时间,毫秒
   * @param offL 从本周偏移几周, 0 表示本周,-1 表示上一周,1 表示下一周
   * @param offR 从本周偏移几周, 0 表示本周,-1 表示上一周,1 表示下一周
   * @return 时间范围(毫秒级别)
   */
  public static Date[] weeks(long base, int offL, int offR) {
    int from = Math.min(offL, offR);
    int len = Math.abs(offL - offR);
    // 现在
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(base);

    Date[] re = new Date[2];

    // 计算开始
    c.setTimeInMillis(c.getTimeInMillis() + MS_WEEK * from);
    c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    re[0] = c.getTime();

    // 计算结束
    c.setTimeInMillis(c.getTimeInMillis() + MS_WEEK * (len + 1) - 1000);
    c.set(Calendar.HOUR_OF_DAY, 23);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    re[1] = c.getTime();

    // 返回
    return re;
  }
  private void initOtherComponents() {
    Calendar now = Calendar.getInstance();
    toDatejSpinner.setValue(now.getTime());
    now.add(Calendar.MONTH, -6);
    fromDatejSpinner.setValue(now.getTime());

    exchangeJComboBox.setModel(
        new DefaultComboBoxModel(mainJFrame.mappingExchangeID_Assets.keySet().toArray()));
    exchangeComboKeyHandler = new ComboKeyHandler(exchangeJComboBox);
    JTextField fieldExchange = (JTextField) exchangeJComboBox.getEditor().getEditorComponent();
    fieldExchange.addKeyListener(exchangeComboKeyHandler);

    assetJComboBox.setModel(
        new DefaultComboBoxModel(
            mainJFrame.mappingExchangeID_Assets.get(
                (ExchangeEntity) exchangeJComboBox.getSelectedItem())));
    assetComboKeyHandler = new ComboKeyHandler(assetJComboBox);
    JTextField fieldSymbol = (JTextField) assetJComboBox.getEditor().getEditorComponent();
    fieldSymbol.addKeyListener(assetComboKeyHandler);

    asset = (AssetEntity) assetJComboBox.getSelectedItem();
    toDate = (Date) toDatejSpinner.getValue();
    fromDate = (Date) fromDatejSpinner.getValue();

    newAddDecAlgJDialog();
    newAddCriteriaJDialog();
    newImportPortfolioJDialog();
  }
  private List<Long> getPayUsers(Calendar calendar) {
    List<Long> payUserIds = new ArrayList<Long>();

    Calendar calendar1 = Calendar.getInstance();
    calendar1.setTime(calendar.getTime());
    calendar1.set(Calendar.HOUR_OF_DAY, 0);
    calendar1.set(Calendar.MINUTE, 0);
    calendar1.set(Calendar.SECOND, 0);

    Calendar calendar2 = Calendar.getInstance();
    calendar2.setTime(calendar.getTime());
    calendar2.set(Calendar.HOUR_OF_DAY, 23);
    calendar2.set(Calendar.MINUTE, 59);
    calendar2.set(Calendar.SECOND, 59);
    try {
      PreparedStatement pstmt =
          orderCon.prepareStatement(
              "select distinct(uid) from ordersqq where time between ? and ? and cmd=7");
      pstmt.setLong(1, calendar1.getTimeInMillis());
      pstmt.setLong(2, calendar2.getTimeInMillis());
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        payUserIds.add(rs.getLong(1));
      }
    } catch (Exception e) {
      logger.error("", e);
    }

    return payUserIds;
  }
 private void caricaPubblicazioni() {
   String testo =
       "Antichi palazzi costruiti su un'alta collina, un intreccio di viuzze e scalinate, diverse piazzette caratteristiche, un paronama incantevole, unico, l'aria salubre, fresca, questa è Colonnella."
           + "Le mie \"estati\" sono abruzzesi e quindi conosco bene "
           + "dell'Abruzzo il colore e il senso dell'estate, quando "
           + "dai treni che mi riportavano a casa da lontani paesi, "
           + "passavano per il Tronto e rivedevo le prime case coloniche "
           + "coi mazzi di granturco sui tetti, le spiagge libere ancora, "
           + "i paesi affacciati su quei loro balconi naturali di colline, "
           + "le più belle che io conosca.";
   Calendar dal = Calendar.getInstance();
   dal.setTime(new Date());
   dal.add(Calendar.MONTH, -1);
   Calendar al = Calendar.getInstance();
   al.setTime(new Date());
   al.add(Calendar.MONTH, 1);
   TipoPubblicazione tipo = tipoPubblicazioneRepository.find(new Long(4));
   for (int i = 0; i < 1000; i++) {
     Pubblicazione pubblicazione = new Pubblicazione();
     pubblicazione.setAl(al.getTime());
     pubblicazione.setDal(dal.getTime());
     pubblicazione.setAttivo(true);
     pubblicazione.setAutore("flower");
     pubblicazione.setDescrizione(testo);
     pubblicazione.setNome("pubblicazione" + i);
     pubblicazione.setTitolo("pubblicazione" + i);
     pubblicazione.setData(new Date());
     pubblicazione.setTipo(tipo);
     String idTitle = PageUtils.createPageId(pubblicazione.getNome());
     String idFinal = testPubbId(idTitle);
     pubblicazione.setId(idFinal);
     pubblicazioniRepository.persist(pubblicazione);
   }
 }
  /**
   * 生成查询参数Map
   *
   * @return Map<String, Object>
   */
  private Map<String, Object> genParamMap(String condition) {
    Map<String, Object> params = new HashMap<String, Object>();

    if ("default".equals(flag)) {
      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
      String eDate = dateFormat.format(cal.getTime());
      cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 6);
      String sDate = dateFormat.format(cal.getTime());
      params.put("beginDate", sDate);
      params.put("endDate", eDate);

      // 设置日期过滤框默认值
      statParams.put("beginDate", sDate);
      statParams.put("endDate", eDate);
    }

    if (StringUtils.isNotBlank(statParams.get("processType"))) {
      params.put("processType", statParams.get("processType"));
    }

    if (StringUtils.isNotBlank(statParams.get("beginDate"))) {
      params.put("beginDate", statParams.get("beginDate"));
    }

    if (StringUtils.isNotBlank(statParams.get("endDate"))) {
      params.put("endDate", statParams.get("endDate"));
    }

    return params;
  }
Exemple #22
0
 public static List<Date[]> getDays(Date from, Date to) {
   List<Date[]> list = new ArrayList<Date[]>();
   Date[] fromto;
   Calendar c = Calendar.getInstance();
   c.setTime(from);
   Calendar cTo = Calendar.getInstance();
   cTo.setTime(to);
   /*fromto = new Date[2];
   fromto[0] = c.getTime();
   fromto[1] = cTo.getTime();
   list.add(fromto);
   return list;*/
   while (c.before(cTo)) {
     if (c.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY
         || c.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
       Date lFrom = c.getTime();
       Calendar lCal = Calendar.getInstance();
       lCal.setTime(lFrom);
       lCal.add(Calendar.DAY_OF_YEAR, 2);
       Date lTo = lCal.getTime();
       fromto = new Date[2];
       fromto[0] = lFrom;
       fromto[1] = lTo;
       list.add(fromto);
     }
     c.add(Calendar.DAY_OF_YEAR, 1);
   }
   return list;
 }
  public void testBasicOffsets() {
    GPCalendarCalc calendar = GPCalendarCalc.PLAIN;
    Date start = TestSetupHelper.newMonday().getTime();

    OffsetBuilder builder =
        new OffsetBuilderImpl.FactoryImpl()
            .withStartDate(start)
            .withViewportStartDate(start)
            .withCalendar(calendar)
            .withTopUnit(GPTimeUnitStack.WEEK)
            .withBottomUnit(GPTimeUnitStack.DAY)
            .withAtomicUnitWidth(20)
            .withEndOffset(210)
            .withWeekendDecreaseFactor(1.0f)
            .build();
    OffsetList bottomUnitOffsets = new OffsetList();
    builder.constructOffsets(new ArrayList<Offset>(), bottomUnitOffsets);

    assertEquals(11, bottomUnitOffsets.size());
    assertEquals(20, bottomUnitOffsets.get(0).getOffsetPixels());
    assertEquals(220, bottomUnitOffsets.get(10).getOffsetPixels());

    Calendar c = (Calendar) Calendar.getInstance().clone();
    c.setTime(start);
    c.add(Calendar.DAY_OF_YEAR, 11);
    assertEquals(c.getTime(), bottomUnitOffsets.get(10).getOffsetEnd());

    c.add(Calendar.DAY_OF_YEAR, -1);
    assertEquals(c.getTime(), bottomUnitOffsets.get(10).getOffsetStart());
  }
Exemple #24
0
 public static List<Date[]> getDays(int year, int month) {
   List<Date[]> list = new ArrayList<Date[]>();
   Date[] fromto;
   Calendar c = Calendar.getInstance();
   c.clear();
   c.set(year, month, 0);
   int days;
   if (month >= 0) days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
   else days = c.getActualMaximum(Calendar.DAY_OF_YEAR);
   for (int i = 0; i < days; i++) {
     c.add(Calendar.DAY_OF_YEAR, 1);
     if (c.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY
         || c.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
       Date from = c.getTime();
       c.add(Calendar.DAY_OF_YEAR, 2);
       Date to = c.getTime();
       // Date to = new Date(from.getTime() + (INTERVAL_IN_MS * 2));
       fromto = new Date[2];
       fromto[0] = from;
       fromto[1] = to;
       list.add(fromto);
     }
   }
   return list;
 }
Exemple #25
0
  protected void makeGantt() {
    gantt_ = new GanttTable(makeTableModel(model_));

    // System.out.println("model rows:"+model.getTableModel().getRowCount());
    TableColumnModel columnModel = gantt_.getColumnModel(1);
    TableColumn column = columnModel.getColumn(0);

    // Enable drag and drop
    TableCellEditor editor = gantt_.getDefaultEditor(1, AbstractDrawingState.class);
    column.setCellEditor(editor);

    gantt_
        .getDrawingContext()
        .put(ContextConstants.EDITING_AXIS, ContextResources.OTHER_PROPERTY, GanttTable.TIME_AXIS);

    gantt_
        .getDrawingContext()
        .put(
            ContextConstants.EDITING_MODE,
            ContextResources.OTHER_PROPERTY,
            EditorDrawingModule.MOVE_RESIZE_EDITOR);

    // Display timeline at the top
    column.setHeaderValue(GanttEntryHelper.createCalendar());
    gantt_.setTimeRange(start_.getTime(), end_.getTime());
    gantt_.addMouseMotionListener(this);

    /* TODO: Disable row selection?
    JTable activityTable = gantt_.getTableComponent(1);
    activityTable.setRowSelectionAllowed(false);
    activityTable.setColumnSelectionAllowed(false);
    activityTable.setCellSelectionEnabled(false);
    */
  }
  /**
   * Method is return the academic day count.
   *
   * @param attendanceDashboardDto type AttendanceDashboardDto
   * @return academic days type integer
   * @throws AkuraAppException - The exception details that occurred when processing.
   */
  private int getAcademicDays(AttendanceDashboardDto attendanceDashboardDto)
      throws AkuraAppException {

    Date fDate = null;
    Date tDate = null;

    int year = attendanceDashboardDto.getYear();
    if (attendanceDashboardDto.getMonth() == 0) {

      fDate = DateUtil.getFistDayOfSelectedYearMonth(year, 1);
      tDate = DateUtil.getLastDayOfSelectedYearMonth(year, MONTH_DECEMBER);
    } else {
      fDate = DateUtil.getFistDayOfSelectedYearMonth(year, attendanceDashboardDto.getMonth());
      tDate = DateUtil.getLastDayOfSelectedYearMonth(year, attendanceDashboardDto.getMonth());
    }

    Calendar firstDateOfPreviousMonth = Calendar.getInstance();
    Calendar lastDateOfPreviousMonth = Calendar.getInstance();
    firstDateOfPreviousMonth.setTime(fDate);
    lastDateOfPreviousMonth.setTime(tDate);

    List<Holiday> holidayList =
        commonService.findHolidayByYear(
            firstDateOfPreviousMonth.getTime(), lastDateOfPreviousMonth.getTime());

    return HolidayUtil.countWorkingDays(
        firstDateOfPreviousMonth, lastDateOfPreviousMonth, holidayList);
  }
 public void drawString(Graphics g) {
   Font Amonth = new Font("Century Gothic", Font.PLAIN, 45);
   g.setColor(Color.gray);
   g.setFont(Amonth);
   g.drawString(month.format(today.getTime()), 150, 45);
   Month = present.format(today.getTime());
 }
  public void aggregateParameterTest() {
    EntityManager em = createEntityManager();

    ExpressionBuilder builder = new ExpressionBuilder();
    ReportQuery query =
        new ReportQuery(
            org.eclipse.persistence.testing.models.jpa.advanced.Employee.class, builder);
    query.returnWithoutReportQueryResult();
    query.addItem("employee", builder);

    org.eclipse.persistence.testing.models.jpa.advanced.EmploymentPeriod period =
        new EmploymentPeriod();
    Calendar startCalendar = Calendar.getInstance();
    Calendar endCalendar = Calendar.getInstance();
    startCalendar.set(1901, 11, 31, 0, 0, 0);
    endCalendar.set(1995, 0, 12, 0, 0, 0);
    period.setStartDate(new java.sql.Date(startCalendar.getTime().getTime()));
    period.setEndDate(new java.sql.Date(endCalendar.getTime().getTime()));
    Expression exp = builder.get("period").equal(builder.getParameter("period"));
    query.setSelectionCriteria(exp);
    query.addArgument("period", EmploymentPeriod.class);

    Vector args = new Vector();
    args.add(period);

    List expectedResult = (Vector) getServerSession().executeQuery(query, args);

    List result =
        em.createQuery("SELECT e FROM Employee e WHERE e.period = :period ")
            .setParameter("period", period)
            .getResultList();

    Assert.assertTrue(
        "aggregateParameterTest failed", comparer.compareObjects(expectedResult, result));
  }
 public int obtenerDiasHabiles(Date fecha, Date fecha2) {
   Calendar calendario = Calendar.getInstance();
   calendario.setTimeZone(TimeZone.getTimeZone("GMT-4:00"));
   calendario.setTime(fecha2);
   calendario.add(Calendar.DAY_OF_YEAR, +1);
   calendario.set(Calendar.HOUR, 0);
   calendario.set(Calendar.HOUR_OF_DAY, 0);
   calendario.set(Calendar.SECOND, 0);
   calendario.set(Calendar.MILLISECOND, 0);
   calendario.set(Calendar.MINUTE, 0);
   fecha2 = calendario.getTime();
   calendario.setTime(fecha);
   String fija = formatoFecha.format(fecha2);
   String hoy = "";
   int contador = 0;
   do {
     calendario.setTime(fecha);
     if (calendario.get(Calendar.DAY_OF_WEEK) != 1 && calendario.get(Calendar.DAY_OF_WEEK) != 7)
       contador++;
     calendario.add(Calendar.DAY_OF_YEAR, +1);
     fecha = calendario.getTime();
     hoy = formatoFecha.format(fecha);
   } while (!hoy.equals(fija));
   return contador;
 }
  /**
   * 生成查询参数Map
   *
   * @return Map<String, Object>
   * @throws ParseException
   */
  private Map<String, Object> genParamMap(String condition) throws ParseException {
    Map<String, Object> params = new HashMap<String, Object>();

    if ("default".equals(flag)) {
      calendar.setTime(new Date());
      calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) - 1);
      String eDate = dateFormat.format(calendar.getTime());
      calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) - 6);
      String sDate = dateFormat.format(calendar.getTime());
      params.put("beginDate", sDate);
      params.put("endDate", eDate);

      // 设置日期过滤框默认值
      statParams.put("beginDate", sDate);
      statParams.put("endDate", eDate);
    }

    if (StringUtils.isNotBlank(statParams.get("beginDate"))) {
      params.put("beginDate", statParams.get("beginDate"));
    }

    if (StringUtils.isNotBlank(statParams.get("endDate"))) {
      params.put("endDate", statParams.get("endDate"));
    }

    // 订单号
    if (StringUtils.isNotBlank(orderCode)) params.put("orderCode", orderCode.trim());
    // 物料编码
    if (StringUtils.isNotBlank(materialCode)) params.put("materialCode", materialCode.trim());

    return params;
  }