Example #1
0
  public Ticket(String name, Double cena) {
    this.name = name;
    this.cena = cena;

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
    Date aktDate = new Date();
    aktDate.setHours(aktDate.getHours() - 2);
    aktDate.setMinutes(aktDate.getMinutes() - 15);
    this.zakupiony = sdf.format(aktDate);
    Date waznyDo = aktDate;
    waznyDo.setHours(waznyDo.getHours() + 24);
    this.wazny = sdf.format(waznyDo);
    Random r = new Random();
    this.nrKontrolny = this.nrKontrolny + String.format("%03d%n", r.nextInt(999)).trim();
    this.nrTrn = this.nrTrn + this.nrTrnMod + String.format("%03d%n", r.nextInt(999)).trim();

    this.url = this.url + getNrTrn();

    /* utworzenie QR Code i konwersja do bitmapy */
    QRCodeEncoder qrCodeEncoder =
        new QRCodeEncoder(url, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), 600);
    try {
      this.bitmap = qrCodeEncoder.encodeAsBitmap();
    } catch (WriterException e) {
      e.printStackTrace();
    }
  }
  @Override
  public ArrayList<Pay> getPaysIn(Date begin, Date end, int numPage, int quantity) {
    begin.setHours(0);
    begin.setMinutes(0);
    begin.setSeconds(0);
    end.setHours(23);
    end.setMinutes(59);
    end.setSeconds(59);

    String sqlQuery =
        "select *"
            + ", u.id AS user_id, u.name AS user_name, u.email AS user_email, u.login AS user_login"
            + ", man.id AS manufacturer_id, man.name AS manufacturer_name"
            + ", cl.id AS client_id, cl.name AS client_name, cl.email AS client_email, cl.address AS client_address"
            + " from pays "
            + " left join users AS u on (pays.user=u.id)"
            + " left join client AS cl on (pays.client=cl.id)"
            + " left join manufacturer AS man on (pays.manufacturer=man.id)"
            + ((begin.getTime() < end.getTime())
                ? " where (pays.time<=:end) and (pays.time>=:begin) "
                : "")
            + " order by pays.time desc, pays.demand_id";

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("quantity", quantity);
    params.addValue("numPage", numPage - 1);
    params.addValue("begin", begin);
    params.addValue("end", end);

    try {
      return (ArrayList<Pay>) jdbcTemplate.query(sqlQuery, params, new PayRowMapper());
    } catch (EmptyResultDataAccessException e) {
      return new ArrayList<Pay>();
    }
  }
  @Override
  public ArrayList<Pay> getPaysForReport(Date begin, Date end, int marketing_id, int mainFirm_id) {
    begin.setHours(0);
    begin.setMinutes(0);
    begin.setSeconds(0);
    end.setHours(23);
    end.setMinutes(59);
    end.setSeconds(59);

    String sqlQuery =
        "select *"
            + ", u.id AS user_id, u.name AS user_name, u.email AS user_email, u.login AS user_login"
            + ", man.id AS manufacturer_id, man.name AS manufacturer_name"
            + ", cl.id AS client_id, cl.name AS client_name, cl.email AS client_email, cl.address AS client_address"
            + " from pays "
            + " left join users AS u on (pays.user=u.id)"
            + " left join client AS cl on (pays.client=cl.id)"
            + " left join manufacturer AS man on (pays.manufacturer=man.id)"
            + " where (pays.time>=:begin) and (pays.time<=:end) and ((pays.manufacturer=:marketing_id) or (pays.manufacturer=:mainFirm_id)) "
            + " and (((pays.summ>0) and (pays.storno=0)) or ((pays.summ<0) and (pays.storno=1))) order by pays.time, pays.manufacturer";

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("marketing_id", marketing_id);
    params.addValue("mainFirm_id", mainFirm_id);
    params.addValue("begin", begin);
    params.addValue("end", end);

    try {
      return (ArrayList<Pay>) jdbcTemplate.query(sqlQuery, params, new PayRowMapper());
    } catch (EmptyResultDataAccessException e) {
      return new ArrayList<Pay>();
    }
  }
  /*validar horas adicionales*/
  public void validarHoraAdicional() {
    String ts_reg;
    String ts_sal;
    Date d1;
    Date d_reg;
    Date d_sal;
    SimpleDateFormat formatTimeStamp;
    formatTimeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    this.setOncomplete("");
    try {
      d1 = this.getNuevaHoraAdicional().getN_fsesion();

      d_reg = new Date(d1.getTime());
      d_reg.setHours(nuevaHoraAdicional.getReg_hora());
      d_reg.setMinutes(nuevaHoraAdicional.getReg_min());
      nuevaHoraAdicional.setN_fsesion_ini(d_reg);

      d_sal = new Date(d1.getTime());
      d_sal.setHours(nuevaHoraAdicional.getSal_hora());
      d_sal.setMinutes(nuevaHoraAdicional.getSal_min());
      nuevaHoraAdicional.setN_fsesion_fin(d_sal);

      ts_reg = formatTimeStamp.format(d_reg);
      ts_sal = formatTimeStamp.format(d_sal);

      if (nuevaHoraAdicional.getN_doc_id() == 0) {
        oncomplete = "javascript:alert('SELECCIONE UN DOCENTE');";
      } else if ("0".equals(nuevaHoraAdicional.getCentro())) {
        oncomplete = "javascript:alert('SELECCIONE UN CENTRO');";
      } else if (nuevaHoraAdicional.getIdArea() == 0) {
        oncomplete = "javascript:alert('SELECCIONE UN ÁREA');";
      } else if (nuevaHoraAdicional.getIdMod() == 0) {
        oncomplete = "javascript:alert('SELECCIONE UN MÓDULO');";
      } else if (nuevaHoraAdicional.getIdCur() == 0) {
        oncomplete = "javascript:alert('SELECCIONE UN CURSO');";
      } else if (nuevaHoraAdicional.getIdSec() == 0) {
        oncomplete = "javascript:alert('SELECCIONE UNA SECCIÓN');";
      } else if (nuevaHoraAdicional.getReg_hora() == 0 || nuevaHoraAdicional.getSal_hora() == 0) {
        oncomplete = "javascript:alert('INGRESE HORAS');";
      } else if (ts_reg.compareTo(ts_sal) > 0) {
        oncomplete = "javascript:alert('LA HORA DE INICIO NO PUEDE SER MAYOR QUE LA DE FIN');";
      } else if ("0".equalsIgnoreCase(nuevaHoraAdicional.getN_tipses_code())) {
        oncomplete = "javascript:alert('INGRESE UN TIPO DE SESION');";
      } else {
        horaAdicional();
        this.setOncomplete(
            "javascript:alert('SE INGRESO LA NUEVA SESSION');"
                + "Richfaces.hideModalPanel('mpHoraAdicional')");
      }
    } catch (NullPointerException npe) {
      this.setOncomplete("javascript:alert('INGRESE FECHAS');");
    }
  }
Example #5
0
 public void onTimeSet(TimePicker view, boolean hasTime, int hourOfDay, int minute) {
   if (!hasTime) {
     customDate.setHours(0);
     customDate.setMinutes(0);
     customDate.setSeconds(0);
   } else {
     customDate.setHours(hourOfDay);
     customDate.setMinutes(minute);
     existingDateHour = hourOfDay;
     existingDateMinutes = minute;
   }
   customDateFinished();
 }
  public static void SincronizarPassado(
      Context context, Integer id_empresa, Integer id_transportadora, String ds_visao)
      throws Exception {
    Calendar aCalendar = Calendar.getInstance();

    aCalendar.add(Calendar.MONTH, -1);

    aCalendar.set(Calendar.DATE, 1);

    Date _inicio = aCalendar.getTime();

    aCalendar.set(Calendar.DATE, aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));

    Date _fim = aCalendar.getTime();

    String server = "";
    Integer idempresa = 0;
    Integer idvendedor = 0;

    DAOParametros tabelaParametros = new DAOParametros(context);
    tabelaParametros.open();
    String SOAP_ADDRESS =
        new DAOParametros(context).GetParametroWebservice("ds_webservice").getDs_valor();
    tabelaParametros.close();

    _inicio.setHours(0);
    _inicio.setMinutes(0);
    _inicio.setSeconds(0);

    _fim.setHours(23);
    _fim.setMinutes(59);
    _fim.setSeconds(59);

    ArrayList<TB_DADOS> itens =
        RetornaLista(context, SOAP_ADDRESS, id_empresa, id_transportadora, ds_visao, _inicio, _fim);

    if (itens == null) return;

    DAODados tabelaDados = new DAODados(context);
    tabelaDados.open();

    // Incluir todas as visitas..
    for (TB_DADOS item : itens) {
      item.setNr_data_referencia(-1);
      tabelaDados.insert(item);
    }

    tabelaDados.close();
  }
Example #7
0
  void timeBlockClick(int x, int y) {

    int left = dayViewBody.getGrid().gridOverlay.getAbsoluteLeft();
    int top = dayViewBody.getScrollPanel().getAbsoluteTop();
    int width = dayViewBody.getGrid().gridOverlay.getOffsetWidth();
    //        int scrollOffset = dayViewBody.getScrollPanel().getScrollPosition();

    // x & y are based on screen position,need to get x/y relative to
    // component
    //        int relativeY = y - top + scrollOffset;
    int relativeY = y - top;
    int relativeX = x - left;

    // find the interval clicked and day clicked
    double interval = Math.floor(relativeY / (double) getSettings().getPixelsPerInterval());
    double day =
        Math.floor((double) relativeX / ((double) width / (double) calendarWidget.getDays()));

    // create new appointment date based on click
    Date newStartDate = calendarWidget.getDate();
    newStartDate.setHours(0);
    newStartDate.setMinutes(0);
    newStartDate.setSeconds(0);
    newStartDate.setMinutes((int) interval * (60 / getSettings().getIntervalsPerHour()));
    newStartDate.setDate(newStartDate.getDate() + (int) day);

    calendarWidget.fireTimeBlockClickEvent(newStartDate);
  }
Example #8
0
 @SuppressWarnings("deprecation")
 public static ListGridRecord toRecord(final SearchResult searchResult) {
   final ListGridRecord record = new ListGridRecord();
   record.setAttribute("id", searchResult.getTropixObject().getId());
   record.setAttribute("name", StringUtils.sanitize(searchResult.getTropixObject().getName()));
   record.setAttribute(
       "description", StringUtils.sanitize(searchResult.getTropixObject().getDescription()));
   record.setAttribute(
       "icon", ModelFunctions.getIconFunction16().apply(searchResult.getTropixObject()));
   if (searchResult.getTropixObject().getCreationTime() != null) {
     final Date creationDate =
         new Date(Long.parseLong(searchResult.getTropixObject().getCreationTime()));
     // Deprecated methods needed because GWT lacks java.util.Calandar class...
     creationDate.setHours(0);
     creationDate.setMinutes(0);
     creationDate.setSeconds(0);
     record.setAttribute("creationDate", creationDate);
   }
   final String ownerDisplay =
       searchResult.getOwner().substring(searchResult.getOwner().lastIndexOf('=') + 1);
   record.setAttribute("owner", ownerDisplay);
   record.setAttribute(
       "object", new TropixObjectContext<TropixObject>(searchResult.getTropixObject()));
   return record;
 }
  @SuppressWarnings("deprecation")
  private final Date extractStartDate(OTTDataContainer dataContainer, boolean isPerformance) {
    Date startDate = null;
    for (Locomotive locomotive : dataContainer.locomotives.values()) {
      for (StationData stationData : locomotive.trips.values()) {
        if (isPerformance) {
          if (startDate == null) {
            startDate = new Date(stationData.arrival.getTime());
          } else if (stationData.arrival.getTime() < startDate.getTime()) {
            startDate.setTime(stationData.arrival.getTime());
          }
        } else {
          long time =
              stationData.arrival.getTime() - (stationData.delayArrival.longValue() * 1000L);
          if (startDate == null) {
            startDate = new Date(time);
          } else if (time < startDate.getTime()) {
            startDate.setTime(time);
          }
        }
      }
    }

    startDate.setHours(0);
    startDate.setMinutes(0);
    startDate.setSeconds(0);
    return startDate;
  }
 /** Compute long due date from DateValue */
 private static long buildNewDueDate(Date original, DateValue nextDate) {
   long newDueDate;
   if (nextDate instanceof DateTimeValueImpl) {
     DateTimeValueImpl newDateTime = (DateTimeValueImpl) nextDate;
     Date date =
         new Date(
             Date.UTC(
                 newDateTime.year() - 1900,
                 newDateTime.month() - 1,
                 newDateTime.day(),
                 newDateTime.hour(),
                 newDateTime.minute(),
                 newDateTime.second()));
     // time may be inaccurate due to DST, force time to be same
     date.setHours(original.getHours());
     date.setMinutes(original.getMinutes());
     newDueDate = Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, date.getTime());
   } else {
     newDueDate =
         Task.createDueDate(
             Task.URGENCY_SPECIFIC_DAY,
             new Date(nextDate.year() - 1900, nextDate.month() - 1, nextDate.day()).getTime());
   }
   return newDueDate;
 }
    /** Return the current date with the time modified as it was set in the time picker. */
    public void onTimeSet(final TimePicker view, final int hourOfDay, final int minute) {
      Date date = new Date();
      date.setHours(hourOfDay);
      date.setMinutes(minute);

      callbackContext.success(date.toLocaleString());
    }
Example #12
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;
  }
Example #13
0
    @Override
    public void readFromTask(Task task) {
      long date = task.getValue(Task.HIDE_UNTIL);

      Date dueDay = new Date(task.getValue(Task.DUE_DATE) / 1000L * 1000L);
      dueDay.setHours(0);
      dueDay.setMinutes(0);
      dueDay.setSeconds(0);

      int selection = 0;
      if (date == 0) {
        selection = 0;
        date = 0;
      } else if (date == dueDay.getTime()) {
        selection = 1;
        date = 0;
      } else if (date + DateUtilities.ONE_DAY == dueDay.getTime()) {
        selection = 2;
        date = 0;
      } else if (date + DateUtilities.ONE_WEEK == dueDay.getTime()) {
        selection = 3;
        date = 0;
      }

      HideUntilValue[] list = createHideUntilList(date);
      adapter =
          new ArrayAdapter<HideUntilValue>(
              TaskEditActivity.this, android.R.layout.simple_spinner_item, list);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      spinner.setAdapter(adapter);

      spinner.setSelection(selection);
    }
Example #14
0
    private void loadMostRecentSections(Cursor c) {
      // Clear any history sections that may have been loaded before.
      mMostRecentSections.clear();

      if (c == null || !c.moveToFirst()) {
        return;
      }

      final Date now = new Date();
      now.setHours(0);
      now.setMinutes(0);
      now.setSeconds(0);

      final long today = now.getTime();
      MostRecentSection section = null;

      do {
        final int position = c.getPosition();
        final long time = c.getLong(c.getColumnIndexOrThrow(URLColumns.DATE_LAST_VISITED));
        final MostRecentSection itemSection =
            MostRecentAdapter.getMostRecentSectionForTime(today, time);

        if (section != itemSection) {
          section = itemSection;
          mMostRecentSections.append(position + mMostRecentSections.size(), section);
        }

        // Reached the last section, no need to continue
        if (section == MostRecentSection.OLDER) {
          break;
        }
      } while (c.moveToNext());
    }
 public void adjustDate(Date d) {
   if (DateIntervalType.MILLENIUM.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 1000);
   }
   if (DateIntervalType.CENTURY.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 100);
   }
   if (DateIntervalType.DECADE.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 10);
   }
   if (DateIntervalType.YEAR.equals(type)) {
     d.setYear(d.getYear() + (int) quantity);
   }
   if (DateIntervalType.QUARTER.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity * 3);
   }
   if (DateIntervalType.MONTH.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity);
   }
   if (DateIntervalType.WEEK.equals(type)) {
     d.setDate(d.getDate() + (int) quantity * 7);
   }
   if (DateIntervalType.DAY.equals(type)) {
     d.setDate(d.getDate() + (int) quantity);
   }
   if (DateIntervalType.HOUR.equals(type)) {
     d.setHours(d.getHours() + (int) quantity);
   }
   if (DateIntervalType.MINUTE.equals(type)) {
     d.setMinutes(d.getMinutes() + (int) quantity);
   }
   if (DateIntervalType.SECOND.equals(type)) {
     d.setSeconds(d.getSeconds() + (int) quantity);
   }
 }
  public Date getStartDate() {
    switch (getScheduleType()) {
      case RUN_ONCE:
        Date startDate = runOnceEditor.getStartDate();
        String startTime = runOnceEditor.getStartTime();
        String[] times = startTime.split(":"); // $NON-NLS-1$
        int hour = Integer.parseInt(times[0]);
        int minute = Integer.parseInt(times[1]);
        if (startTime.indexOf("PM") >= 0) { // $NON-NLS-1$
          hour += 12;
        }

        startDate.setHours(hour);
        startDate.setMinutes(minute);
        startDate.setSeconds(0);
        return startDate;
      case SECONDS: // fall through
      case MINUTES: // fall through
      case HOURS: // fall through
      case DAILY: // fall through
      case WEEKLY: // fall through
      case MONTHLY: // fall through
      case YEARLY:
        return recurrenceEditor.getStartDate();
      case CRON:
        return cronEditor.getStartDate();
      default:
        throw new RuntimeException(MSGS.invalidRunType(getScheduleType().toString()));
    }
  }
Example #17
0
  public static void main(String[] args) throws ParseException {
    //
    // Форматирование даты:
    // * yyyy - год 4 цифры
    // * MM - месяц 2 цифры
    // * dd - день в месяце 2 цифры
    // * HH - час 2 цифры
    // * mm - минута 2 цифры
    // * ss - секунда 2 цифры
    // -->
    Date date = new Date();
    System.out.println("date = " + date);
    SimpleDateFormat dateFormat = new SimpleDateFormat("'Дата и время:' dd.MM.yyyy HH:mm:ss");

    System.out.println(dateFormat.format(date));

    SimpleDateFormat russianDate = new SimpleDateFormat("dd.MM.yyyy");
    Date date2 = russianDate.parse("11.10.2014");
    System.out.println(date2);

    System.out.println(dateFormat.format(date2));

    // Изменяю время, ставлю 10 часов
    date.setHours(10);
    // <--
  }
Example #18
0
 public DayDataVO getBaseDayData(String paramString, Date paramDate) throws SQLException {
   DayDataVO localDayDataVO = null;
   PreparedStatement localPreparedStatement = null;
   ResultSet localResultSet = null;
   paramDate.setHours(0);
   paramDate.setMinutes(0);
   paramDate.setSeconds(0);
   try {
     this.conn = getConn();
     String str =
         "SELECT * FROM (SELECT * FROM HistoryDayData WHERE CommodityID = ? AND TradeDate >= ?  ORDER BY TradeDate) WHERE rownum =1";
     localPreparedStatement = this.conn.prepareStatement(str);
     localPreparedStatement.setString(1, paramString);
     localPreparedStatement.setTimestamp(2, new Timestamp(paramDate.getTime()));
     localResultSet = localPreparedStatement.executeQuery();
     if (localResultSet.next()) {
       localDayDataVO = new DayDataVO();
       localDayDataVO.time = localResultSet.getTimestamp("TradeDate");
       localDayDataVO.openPrice = localResultSet.getFloat("OpenPrice");
       localDayDataVO.highPrice = localResultSet.getFloat("HighPrice");
       localDayDataVO.lowPrice = localResultSet.getFloat("LowPrice");
       localDayDataVO.closePrice = localResultSet.getFloat("ClosePrice");
       localDayDataVO.balancePrice = localResultSet.getFloat("BalancePrice");
       localDayDataVO.totalAmount = localResultSet.getLong("TotalAmount");
       localDayDataVO.totalMoney = localResultSet.getFloat("TotalMoney");
       localDayDataVO.reserveCount = localResultSet.getInt("ReserveCount");
     }
   } finally {
     closeStatement(localResultSet, localPreparedStatement, null);
   }
   return localDayDataVO;
 }
Example #19
0
  @SuppressWarnings("unchecked")
  public List<Task> getWeekTasksStat(String name, String momin, Date startWeek) {
    Query query;
    List<Task> list;
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    query =
        em.createQuery(
            "select from "
                + Task.class.getName()
                + " t where t.mominId = :momin AND  name =:name AND  t.date >= :start  AND  t.date  < :end order by date asc");
    query.setParameter("name", name);

    Task.moveToDay(startWeek, -1);
    startWeek.setHours(0);
    startWeek.setMinutes(0);
    startWeek.setSeconds(0);
    Date end = CalendarUtil.copyDate(startWeek);
    CalendarUtil.addDaysToDate(end, 7);
    query.setParameter("momin", momin);
    query.setParameter("start", startWeek);
    //	    end.setTime(end.getTime()-2000);
    query.setParameter("end", end);
    list = query.getResultList();

    //	    if(group == null)
    //	    	getCache().put(keyWeek, list);

    return list;
  }
Example #20
0
  public XYSeries getDayHistoryData() {
    XYSeries series = new XYSeries("");
    Date date = new Date();
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    String queryString =
        "select sum(usetime),substr(datetime,12,2) from rundata where datetime(datetime) > '"
            + formater.format(date)
            + "' group by substr(datetime,12,2)";
    Log.d(Tag, "getDayHistoryData's query string:" + queryString);

    GenericRawResults<String[]> rawResult = rundataDao.queryRaw(queryString);
    try {
      List<String[]> result = rawResult.getResults();
      for (int n = 0; n < result.size(); n++) {
        double y = Double.parseDouble(result.get(n)[0]);
        double x = Double.parseDouble(result.get(n)[1]);

        Log.d(Tag, "x:" + x + " y:" + y);

        series.add(Number2(x), Number2(y / 3600));
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return series;
  }
Example #21
0
 @SuppressWarnings("deprecation")
 private void readClockPacket(NceReply r) {
   // NceReply priorClockReadPacket = lastClockReadPacket;
   // int priorNceRatio = nceLastRatio;
   // boolean priorNceRunning = nceLastRunning;
   lastClockReadPacket = r;
   // lastClockReadAtTime = internalClock.getTime();
   // log.debug("readClockPacket - at time: " + lastClockReadAtTime);
   nceLastHour = r.getElement(CS_CLOCK_HOURS) & 0xFF;
   nceLastMinute = r.getElement(CS_CLOCK_MINUTES) & 0xFF;
   nceLastSecond = r.getElement(CS_CLOCK_SECONDS) & 0xFF;
   if (r.getElement(CS_CLOCK_1224) == 1) {
     nceLast1224 = true;
   } else {
     nceLast1224 = false;
   }
   if (r.getElement(CS_CLOCK_AMPM) == 'A') {
     nceLastAmPm = true;
   } else {
     nceLastAmPm = false;
   }
   if (issueDeferredGetTime) {
     issueDeferredGetTime = false;
     Date now = internalClock.getTime();
     if (nceLast1224) { // is 24 hour mode
       now.setHours(nceLastHour);
     } else {
       if (nceLastAmPm) { // is AM
         now.setHours(nceLastHour);
       } else {
         now.setHours(nceLastHour + 12);
       }
     }
     now.setMinutes(nceLastMinute);
     now.setSeconds(nceLastSecond);
     internalClock.userSetTime(now);
   }
   int sc = r.getElement(CS_CLOCK_SCALE) & 0xFF;
   if (sc > 0) {
     nceLastRatio = 250 / sc;
   }
   if (r.getElement(CS_CLOCK_STATUS) == 1) {
     // nceLastRunning = false;
   } else {
     // nceLastRunning = true;
   }
 }
 public void onClick(View arg0) {
   _init.setYear(_datePicker.getYear() - 1900);
   _init.setMonth(_datePicker.getMonth());
   _init.setDate(_datePicker.getDayOfMonth());
   _init.setHours(_timePicker.getCurrentHour());
   _init.setMinutes(_timePicker.getCurrentMinute());
   sendResult(_callback, _init, _opaque);
 }
  @SuppressWarnings("deprecation")
  public int nextPeakBoundary(Date time) {

    Date nextPeak = new Date(time.getTime());
    if (nextPeak.getHours() < startPeakTime) {
      nextPeak.setHours(startPeakTime);
      nextPeak.setMinutes(0);
      nextPeak.setSeconds(0);
    } else {
      nextPeak.setHours(7);
      nextPeak.setMinutes(0);
      nextPeak.setSeconds(0);
      nextPeak = new Date(nextPeak.getTime() + 24 * 60 * 60 * 1000);
    }

    return (int) (nextPeak.getTime() / 1000);
  }
Example #24
0
 /**
  * This is a convenient method to get yesterday date
  *
  * @return
  */
 public static Date yesterday() {
   Calendar c = Calendar.getInstance();
   c.add(Calendar.DATE, -1);
   Date d = c.getTime();
   d.setHours(0);
   d.setMinutes(0);
   return d;
 }
Example #25
0
 private void completeCalendar() {
   List<DayEnum> dayEnums = DayEnum.getDayEnums();
   Date fromHour = new Date();
   fromHour.setHours(0);
   fromHour.setMinutes(0);
   fromHour.setSeconds(0);
   Date toHour = new Date();
   toHour.setHours(23);
   toHour.setMinutes(0);
   toHour.setSeconds(0);
   for (DayEnum dayEnum : dayEnums) {
     DayRange aux = new DayRange();
     aux.setDayEnum(dayEnum);
     aux.setRange(fromHour, toHour);
     calendar.add(aux);
   }
 }
 @SuppressWarnings("deprecation")
 public int nextOffPeakBoundary(Date time) {
   Date nextPeak = new Date(time.getTime());
   nextPeak.setHours(endPeakTime);
   nextPeak.setMinutes(0);
   nextPeak.setSeconds(0);
   return (int) (nextPeak.getTime() / 1000);
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View v = null;
      TATomato item = getTomato(position);
      Context context = TATomatoListActivity.this;
      if (convertView == null) {
        v = getLayoutInflater().inflate(R.layout.tomato, null);
      } else {
        v = convertView;
      }

      ((TextView) v.findViewById(R.id.date))
          .setText(item.getString(context, StringFilter.StartDate));
      ((TextView) v.findViewById(R.id.start))
          .setText(item.getString(context, StringFilter.StartTime));
      ((TextView) v.findViewById(R.id.end)).setText(item.getString(context, StringFilter.EndTime));
      ((TextView) v.findViewById(R.id.duration))
          .setText(item.getString(context, StringFilter.Duration));

      String tomatoNote = TATomatoPersistence.loadTomatoNote(context, item.getId());
      if (tomatoNote == null) {
        tomatoNote = "";
      }
      ((TextView) v.findViewById(R.id.note)).setText(tomatoNote);

      if (isActivityForMultiProjects()) {
        String name = TATomatoPersistence.getProjectName(context, item.getId());
        if (name == null) {
          name = "no project";
        }
        ((TextView) v.findViewById(R.id.project)).setText(name);
      }

      Date date = new Date();
      date.setTime(item.startMs);
      date.setHours(0);
      date.setMinutes(0);
      date.setSeconds(0);
      int msPerDay = 1000 * 60 * 60 * 24;
      float x1 = item.startMs - date.getTime();
      x1 /= msPerDay;
      float x2 = item.getDurationMs();
      x2 /= msPerDay;

      setWeight(v, R.id.pastInDay, x1);
      setWeight(v, R.id.nowInDay, x2);
      setWeight(v, R.id.futureInDay, 1 - x1 - x2);

      final RatingBar ratingbar = (RatingBar) v.findViewById(R.id.rating);
      final float rating = TATomatoPersistence.loadTomatoRating(context, item.getId());
      if (rating > 0) {
        ratingbar.setVisibility(View.VISIBLE);
        ratingbar.setNumStars((int) rating);
      } else {
        ratingbar.setVisibility(View.INVISIBLE);
      }
      return v;
    }
 @SuppressWarnings("deprecation")
 public void setData(Date data) {
   if (data != null) {
     data.setHours(0);
     data.setMinutes(0);
     data.setSeconds(0);
   }
   this.data = data;
 }
Example #29
0
  public static Date today() {
    Calendar c = Calendar.getInstance();

    Date d = c.getTime();
    d.setHours(0);
    d.setMinutes(0);

    return d;
  }
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
          mHour = hourOfDay;
          mMinute = minute;
          updateDisplay();

          timeToSend = Calendar.getInstance().getTime();
          timeToSend.setHours(mHour);
          timeToSend.setMinutes(mMinute);
        }