/**
  * 获取更新的时间
  *
  * @param date
  * @return
  */
 public static String getCreateString_PG(Date date) {
   Calendar calendar = Calendar.getInstance();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   if (calendar.get(Calendar.YEAR) - (date.getYear() + 1900) > 0) {
     return sdf.format(date);
   } else if (calendar.get(Calendar.MONTH) - date.getMonth() > 0
       && calendar.get(Calendar.MONTH) - date.getMonth() < 12) {
     int i = calendar.get(Calendar.MONTH) - date.getDate();
     return i + "个月前";
   } else if ((calendar.get(Calendar.DAY_OF_MONTH) - date.getDate() > 0)
       && (calendar.get(Calendar.DAY_OF_MONTH) - date.getDate() < 30)) {
     int i = calendar.get(Calendar.DAY_OF_MONTH) - date.getDate();
     return i + "天前";
   } else if (calendar.get(Calendar.HOUR_OF_DAY) - date.getHours() > 0) {
     int i = calendar.get(Calendar.HOUR_OF_DAY) - date.getHours();
     return i + "小时前";
   } else if (calendar.get(Calendar.MINUTE) - date.getMinutes() > 0) {
     int i = calendar.get(Calendar.MINUTE) - date.getMinutes();
     return i + "分钟前";
   } else if (calendar.get(Calendar.SECOND) - date.getSeconds() > 0) {
     int i = calendar.get(Calendar.SECOND) - date.getSeconds();
     return i + "秒前";
   } else if (calendar.get(Calendar.SECOND) - date.getSeconds() == 0) {
     return "刚刚";
   } else {
     return sdf.format(date);
   }
 }
Beispiel #2
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();
    }
  }
Beispiel #3
0
  public void calculoHoras(String str_hora_inicial, String str_hora_final) {
    try {
      System.out.println("hora inicial" + str_hora_inicial);
      System.out.println("hora inicial" + str_hora_final);
      Date hora_inicial = utilitario.getHora(utilitario.getFormatoHora(str_hora_inicial));
      Date hora_final = utilitario.getHora(utilitario.getFormatoHora(str_hora_final));
      int total_segundos_hora_inicial =
          (hora_inicial.getHours() * 3600)
              + (hora_inicial.getMinutes() * 60)
              + hora_inicial.getSeconds();
      int total_segundos_hora_final =
          (hora_final.getHours() * 3600) + (hora_final.getMinutes() * 60) + hora_final.getSeconds();

      int total_diferencia_segundo = total_segundos_hora_final - total_segundos_hora_inicial;

      int total_horas = total_diferencia_segundo / 3600;
      int nuevo_valor = total_diferencia_segundo - (total_horas * 3600);
      int total_minutos = nuevo_valor / 60;
      int total_segundos = nuevo_valor - (total_minutos * 60);

      double total_diferencia_segundos =
          ((total_horas * 3600) + (total_minutos * 60) + total_segundos);
      double total_diferencia_horas = total_diferencia_segundos / 3600;

      tab_permisos.setValor(
          tab_permisos.getFilaActual(), "NRO_HORAS_ASPVH", total_diferencia_horas + "");
      utilitario.addUpdateTabla(tab_permisos, "NRO_HORAS_ASPVH", total_diferencia_horas + "");
    } catch (Exception e) {
      // TODO: handle exception
      tab_permisos.setValor(tab_permisos.getFilaActual(), "NRO_HORAS_ASPVH", "");
      utilitario.addUpdateTabla(tab_permisos, "NRO_HORAS_ASPVH", "");
    }
  }
  private boolean timeModificationIsBiggerThanFiveMinutes(
      Date writtenEvaluationStartTime, Date beginningDate) {
    int hourDiference = Math.abs(writtenEvaluationStartTime.getHours() - beginningDate.getHours());
    int minuteDifference =
        Math.abs(writtenEvaluationStartTime.getMinutes() - beginningDate.getMinutes());

    return hourDiference > 0 || minuteDifference > 5;
  }
  @SuppressWarnings("deprecation")
  public static void LogConsole(String type, String info) {
    // Player may be null
    // determine if the log is enabled...
    if (LogIsEnabled) {

      /*
       * File BDir = new File(LogLocation); BDir.mkdir(); File TDir = new
       * File(TLogLocation+type); TDir.mkdir();
       */

      Date date = new Date();

      String LogNameFormatter = LogNameFormat;
      LogNameFormatter = LogNameFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
      LogNameFormatter = LogNameFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
      LogNameFormatter = LogNameFormatter.replace("{DAY}", date.getDate() + "");
      LogNameFormatter = LogNameFormatter.replace("{HOUR}", date.getHours() + "");
      LogNameFormatter = LogNameFormatter.replace("{DTYPE}", type);

      // File Log = new
      // File(TLogLocation+esplitter+type+"/"+LogNameFormatter);

      String LogStringFormatter = LogStringFormat;
      LogStringFormatter = LogStringFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
      LogStringFormatter = LogStringFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
      LogStringFormatter = LogStringFormatter.replace("{DAY}", date.getDate() + "");
      LogStringFormatter = LogStringFormatter.replace("{HOUR}", date.getHours() + "");
      LogStringFormatter = LogStringFormatter.replace("{MINUTE}", date.getMinutes() + "");
      LogStringFormatter = LogStringFormatter.replace("{SECOND}", date.getSeconds() + "");
      LogStringFormatter = LogStringFormatter.replace("{INFO}", info);

      // tekkitrestrict.log.info(LogStringFormatter);
      final String ttype = type;
      final String formattedName = LogNameFormatter;
      final String formatted = LogStringFormatter;
      final String TLogLocation = "log/";
      tekkitrestrict.basfo.execute(
          new Runnable() {

            @Override
            public void run() {
              LogQueue1.add(
                  new String[] {
                    ttype,
                    TLogLocation + ttype,
                    TLogLocation + ttype + "/" + formattedName,
                    formatted + "\n"
                  });
            }
          });
    }
  }
  @SuppressWarnings("deprecation")
  public static void Log(String type, String info) {
    // Player may be null

    // determine if the log is enabled...
    if (LogIsEnabled) {
      String TLogLocation = "plugins/tekkitrestrict/" + LogLocation;
      // File BDir = new File(LogLocation);
      // BDir.mkdir();
      // tekkitrestrict.log.info("tt - "+type);
      // ******************if(type.equals("debug")) tekkitrestrict.log.info("log: "+info);
      if (isLoggable(type)) {
        // tekkitrestrict.log.info("tt - "+type);
        String esplitter = !TLogLocation.endsWith("/") ? "/" : "";
        // File TDir = new File(TLogLocation+esplitter+type);
        // TDir.mkdir();

        Date date = new Date();

        String LogNameFormatter = LogNameFormat;
        LogNameFormatter = LogNameFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
        LogNameFormatter = LogNameFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
        LogNameFormatter = LogNameFormatter.replace("{DAY}", date.getDate() + "");
        LogNameFormatter = LogNameFormatter.replace("{HOUR}", date.getHours() + "");
        LogNameFormatter = LogNameFormatter.replace("{DTYPE}", type);

        // File Log = new
        // File(TLogLocation+esplitter+type+"/"+LogNameFormatter);

        String LogStringFormatter = LogStringFormat;
        LogStringFormatter = LogStringFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
        LogStringFormatter = LogStringFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
        LogStringFormatter = LogStringFormatter.replace("{DAY}", date.getDate() + "");
        LogStringFormatter = LogStringFormatter.replace("{HOUR}", date.getHours() + "");
        LogStringFormatter = LogStringFormatter.replace("{MINUTE}", date.getMinutes() + "");
        LogStringFormatter = LogStringFormatter.replace("{SECOND}", date.getSeconds() + "");
        LogStringFormatter = LogStringFormatter.replace("{INFO}", info);

        // tekkitrestrict.log.info(LogStringFormatter);
        LogQueue.add(
            new String[] {
              type,
              TLogLocation + esplitter + type,
              TLogLocation + esplitter + type + "/" + LogNameFormatter,
              LogStringFormatter + "\n"
            });
      }
    }
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   Date date = new Date();
   date.setTime(System.currentTimeMillis());
   UCCMDAO dao = new UCCMDAO(context);
   if (dao.contaByHora(date.getHours(), date.getMinutes()) > 0) {
     Intent i =
         new Intent(context, AlarmeNotifica.class)
             .putExtra("Hora", date.getHours())
             .putExtra("Minutos", date.getMinutes())
             .putExtra("Som", 1);
     i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     context.startActivity(i);
   }
 }
 /** 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;
 }
Beispiel #9
0
  public void run() {
    Date d1;
    int h, m, s;
    String heure;

    while (!fin) {
      try {
        System.out.println("launch thread");
        d1 = new Date();
        h = d1.getHours();
        m = d1.getMinutes();
        s = d1.getSeconds();

        for (HorlogeListener iphl : AHor) {
          iphl.tic(h, m, s);
        }

        heure = "h: " + h + " m: " + m + " s: " + s;
        System.out.println(heure);
        Hlab.setText(heure);
        Thread.sleep(1000);
      } catch (Exception e) {
      }
    }
  }
Beispiel #10
0
 /**
  * Updates the status of a Light under FAST_CLOCK_CONTROL. This method is called every FastClock
  * minute.
  */
 @SuppressWarnings("deprecation")
 private void updateClockControlLight() {
   if (_clock != null) {
     Date now = _clock.getTime();
     int timeNow = now.getHours() * 60 + now.getMinutes();
     int state = _parentLight.getState();
     if (_timeOn <= _timeOff) {
       // on and off the same day
       if ((timeNow < _timeOn) || (timeNow >= _timeOff)) {
         // Light should be OFF
         if (state == Light.ON) {
           _parentLight.setState(Light.OFF);
         }
       } else {
         // Light should be ON
         if (state == Light.OFF) {
           _parentLight.setState(Light.ON);
         }
       }
     } else {
       // on and off - different days
       if ((timeNow >= _timeOn) || (timeNow < _timeOff)) {
         // Light should be ON
         if (state == Light.OFF) {
           _parentLight.setState(Light.ON);
         }
       } else {
         // Light should be OFF
         if (state == Light.ON) {
           _parentLight.setState(Light.OFF);
         }
       }
     }
   }
 }
Beispiel #11
0
 private String displayTime(String record) {
   if (record.equals("")) return "";
   String[] recordSplit = record.split("-");
   // Warning: pay attention to the following line!
   Date recordDate =
       new Date(
           Integer.parseInt(recordSplit[0]) - 1900,
           Integer.parseInt(recordSplit[1]) - 1,
           Integer.parseInt(recordSplit[2]),
           Integer.parseInt(recordSplit[3]),
           Integer.parseInt(recordSplit[4]));
   Date curDate = new Date(System.currentTimeMillis());
   String[] curSplit =
       DateFormat.format("yyyy-MM-dd-HH-mm-ss", curDate.getTime()).toString().split("-");
   if (recordSplit[2].equals(curSplit[2])) {
     return recordSplit[3] + ":" + recordSplit[4];
   } else {
     double recordTime = recordDate.getTime();
     double curTime = curDate.getTime();
     double delta =
         curDate.getHours() + curDate.getMinutes() / 60.0 + curDate.getSeconds() / 3600.0;
     if (curTime < recordTime) {
       return recordSplit[0] + "/" + recordSplit[1] + "/" + recordSplit[2];
     } else if ((curTime - recordTime) / (1000.0 * 60.0 * 60.0) - delta < 24) {
       return "昨天";
     } else if ((curTime - recordTime) / (1000.0 * 60.0 * 60.0) - delta < 168) {
       String[] day = {"天", "一", "二", "三", "四", "五", "六"};
       Calendar mCalendar = Calendar.getInstance();
       mCalendar.setTime(recordDate);
       return "星期" + day[mCalendar.get(Calendar.DAY_OF_WEEK) - 1];
     } else {
       return recordSplit[0] + "/" + recordSplit[1] + "/" + recordSplit[2];
     }
   }
 }
  public void initTextView() {
    textView = (TextView) findViewById(R.id.textView1);
    textView.setMovementMethod(ScrollingMovementMethod.getInstance());
    textView.setBackgroundColor(Color.argb(232, 200, 200, 169));
    textView.setTextColor(Color.argb(255, 255, 255, 255));

    // 根据时间显示文字
    String name = getResources().getString(R.string.app_master) + ",";
    Date d = new Date();
    int hour = d.getHours();
    int minute = d.getMinutes();
    if (5 <= hour && hour < 11) {
      textView.setHint(name + "早上好!!!");
    } else if (11 <= hour && hour < 15) {
      textView.setHint(name + "中午好!!!");
    } else if (15 <= hour && hour < 18) {
      textView.setHint(name + "下午好!!!");
    } else {
      if (hour == 18 && minute < 30 && minute > 20) {
        textView.setHint(name + "要下班了!!!");
      } else {
        textView.setHint(name + "晚上好!!!");
      }
    }
    //		textView.setHint(textView.getHint().toString()+minute);
  }
Beispiel #13
0
  public static long[] runtimeInSecondsMonth(Context context, long timestamp, boolean monthend) {
    prefs = context.getSharedPreferences(PREFS, 0);
    Date d = new Date(timestamp);
    int month = d.getMonth();
    int year = d.getYear() + 1900;
    long mseconds = prefs.getLong("mseconds_" + month + "_" + year, 0);
    long seconds = mseconds / 1000;
    long secondsthismonth = 0;

    int daysthismonth = d.getDate() - 1;
    if (monthend) {
      daysthismonth = daysthismonth + 5;
    }
    secondsthismonth = daysthismonth * 24 * 60 * 60;
    int hourofday = d.getHours();
    secondsthismonth = secondsthismonth + hourofday * 60 * 60;
    int minuteofhour = d.getMinutes();
    secondsthismonth = secondsthismonth + minuteofhour * 60;
    int secondofminute = d.getSeconds();
    secondsthismonth = secondsthismonth + secondofminute;
    long[] result = new long[2];
    result[0] = seconds;
    result[1] = secondsthismonth;
    return result;
  }
Beispiel #14
0
  public static void writeToLog(String message) {
    int year = calendar.YEAR;
    int month = calendar.MONTH;
    month++;
    int day = calendar.DAY_OF_MONTH;

    String date = year + "-" + month + "-" + day;

    Date time = calendar.getTime();
    int hours = time.getHours();
    int minutes = time.getMinutes();
    int seconds = time.getSeconds();

    String timeS = hours + ":" + minutes + ":" + seconds;

    Date dateS = new Date();

    String timestamp = date + " " + timeS;
    Timestamp ts = new Timestamp(dateS.getTime());

    if (DynamicEconomy.logwriting) {
      try {
        bf.write("\n + [" + ts + "] " + message);
        bf.flush();
      } catch (Exception e) {
        logger.info("[DynamicEconomy] Exception writing to log.txt");
        e.printStackTrace();
      }
    }
  }
Beispiel #15
0
 /**
  * Constructs a TimeOfDay from a <code>java.util.Date</code> using exactly the same field values
  * avoiding any time zone effects.
  *
  * <p>Each field is queried from the Date and assigned to the TimeOfDay. This is useful to ensure
  * that the field values are the same in the created TimeOfDay no matter what the time zone is.
  * For example, if the Calendar states that the time is 04:29, then the created TimeOfDay will
  * always have the time 04:29 irrespective of time zone issues.
  *
  * <p>This factory method always creates a TimeOfDay with ISO chronology.
  *
  * @param date the Date to extract fields from
  * @return the created TimeOfDay
  * @throws IllegalArgumentException if the calendar is null
  * @throws IllegalArgumentException if the date is invalid for the ISO chronology
  * @since 1.2
  */
 public static TimeOfDay fromDateFields(Date date) {
   if (date == null) {
     throw new IllegalArgumentException("The date must not be null");
   }
   return new TimeOfDay(
       date.getHours(), date.getMinutes(), date.getSeconds(), (int) (date.getTime() % 1000));
 }
Beispiel #16
0
 /** set the time, the date part is ignored */
 @SuppressWarnings("deprecation")
 public void setTime(Date now) {
   if (DEBUG_SHOW_PUBLIC_CALLS && log.isDebugEnabled()) {
     log.debug("setTime: " + now);
   }
   issueClockSet(now.getHours(), now.getMinutes(), now.getSeconds());
 }
 @Test
 public void ignoreTime() {
   DateCriterion criterion = new DateCriterion().setDate(3);
   Date date = criterion.getDate();
   assertThat(date.getHours(), is(0));
   assertThat(date.getMinutes(), is(0));
 }
 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);
   }
 }
  private static void writeHeader(IMap map, BufferedWriter out) throws IOException {
    Date now = new Date();
    String id =
        "geodss."
            + now.getYear()
            + now.getMonth()
            + now.getDay()
            + now.getHours()
            + now.getMinutes(); // $NON-NLS-1$

    append(
        0, out, "<OWSContext id=\"" + id + "\" version=\"0.0.13\" "); // $NON-NLS-1$ //$NON-NLS-2$
    append(0, out, "    xmlns=\"http://www.opengis.net/oc\""); // $NON-NLS-1$
    append(0, out, "    xmlns:ogc=\"http://www.opengis.net/ogc\""); // $NON-NLS-1$
    append(0, out, "    xmlns:ows=\"http://www.opengis.net/ows\""); // $NON-NLS-1$
    append(0, out, "    xmlns:param=\"http;//www.opengis.net/param\""); // $NON-NLS-1$
    append(0, out, "    xmlns:sld=\"http://www.opengis.net/sld\""); // $NON-NLS-1$
    append(0, out, "    xmlns:xlink=\"http://www.w3.org/1999/xlink\""); // $NON-NLS-1$
    append(0, out, "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""); // $NON-NLS-1$
    append(
        0,
        out,
        "    xsi:schemaLocation=\"http://www.opengis.net/oc oc_0_0_13.xsd\""); //$NON-NLS-1$
    append(0, out, "    >"); // $NON-NLS-1$
  }
Beispiel #20
0
    private void setDate(CalendarDialog calendarDialog) {
      customDate = calendarDialog.getCalendarDate();
      customDate.setMinutes(0);

      if (customSetting != Task.URGENCY_SPECIFIC_DAY_TIME) {
        customDateFinished();
        return;
      }

      boolean specificTime = existingDateHour != SPECIFIC_DATE;
      if (existingDateHour < 0) {
        existingDateHour = customDate.getHours();
        existingDateMinutes = customDate.getMinutes();
      }

      DeadlineTimePickerDialog timePicker =
          new DeadlineTimePickerDialog(
              TaskEditActivity.this,
              this,
              existingDateHour,
              existingDateMinutes,
              DateUtilities.is24HourFormat(TaskEditActivity.this),
              specificTime);

      timePicker.setOnCancelListener(this);
      timePicker.show();
    }
Beispiel #21
0
 public final void setTimeAsArray(String key, Date value) {
   JsArrayInteger jsArray = JavaScriptObject.createArray().cast();
   jsArray.set(0, value.getHours());
   jsArray.set(1, value.getMinutes());
   jsArray.set(2, value.getSeconds());
   set(key, jsArray);
 };
  @RequestMapping("api/admin/projectAdd.do")
  public @ResponseBody Map<String, Object> projectAdd(
      ProjectDTO fileDto, @RequestParam(value = "memberList") String memberList) {

    MultipartFile uploadFile = fileDto.getUploadFile();

    if (uploadFile != null) {

      String fileName = uploadFile.getOriginalFilename();

      Date date = new Date();
      int year = date.getYear() - 100;
      int month = date.getMonth() + 1;
      int day = date.getDate();
      int hour = date.getHours();
      int minute = date.getMinutes();
      int second = date.getSeconds();
      String time = year + "" + month + "" + day + "" + hour + "" + minute + "" + second;
      int comma = fileName.lastIndexOf(".");
      String pre = fileName.substring(0, comma);
      String end = fileName.substring(comma + 1, fileName.length());
      fileName = pre + time + "." + end;

      String projectDesc = fileDto.getProjectDesc();
      fileDto.setProjectDesc(projectDesc.replaceAll("\n", "<br>"));

      try {

        File file = new File(realPath + fileName);

        uploadFile.transferTo(file);

        fileDto.setProjectImg(fileName);

        System.out.println(memberList);
        JSONParser parser = new JSONParser();
        JSONArray ja = (JSONArray) parser.parse(memberList);
        System.out.println(ja.toJSONString());
        ArrayList list = new ArrayList();
        for (int i = 0; i < ja.size(); i++) {
          JSONObject jo = (JSONObject) ja.get(i);
          System.out.println(jo.get("userNo"));
          list.add(jo.get("userNo"));
        }

        projectDao.insertProject(fileDto);
        if (list != null) {
          Map<String, Object> param = new HashMap<String, Object>();
          param.put("list", list);
          projectMemberDao.projectMemberAdd(param);
        }

      } catch (Exception e) {
        e.printStackTrace();
      } // try - catch
    } // if

    return JsonUtil.putSuccessJsonContainer(null);
  }
  public void addLocationToList(Location cur_location) {

    if (!flag) {
      old_location = cur_location;
      startLat = cur_location.getLatitude();
      startLon = cur_location.getLongitude();
      flag = true;
    } else {
      double destLat = cur_location.getLatitude();
      double destLon = cur_location.getLongitude();
      double distance = getDistance(startLat, startLon, destLat, destLon);
      double dt = (cur_location.getTime() - old_location.getTime()) / 1000;
      double current_speed = distance / dt;
      if (Double.isNaN(current_speed) || (current_speed < 0.001)) current_speed = 0.0;
      Date currentDate = new Date();
      Calendar cal = Calendar.getInstance();
      int hour = currentDate.getHours();
      int minutes = currentDate.getMinutes();
      int seconds = currentDate.getSeconds();
      int year = currentDate.getYear() + 1900;
      int month = currentDate.getMonth() + 1;
      int day = cal.get(Calendar.DAY_OF_MONTH);
      String timestamp =
          String.valueOf(year)
              + "-"
              + String.valueOf(month)
              + "-"
              + String.valueOf(day)
              + " "
              + String.valueOf(hour)
              + ":"
              + String.valueOf(minutes)
              + ":"
              + String.valueOf(seconds);
      String move_type = "?";
      String record =
          String.valueOf(destLat)
              + ","
              + String.valueOf(destLon)
              + ","
              + String.valueOf(current_speed)
              + ","
              + "\""
              + String.valueOf(timestamp)
              + "\""
              + ","
              + String.valueOf(move_type)
              + ","
              + String.valueOf(isGpsFix);
      String type = classifyInstance(record);
      record = record.replace("?", type);
      DataToSend.add(record);
      String curPos = String.valueOf(destLat) + "," + String.valueOf(destLon) + "," + type;
      sendLocationToMap(curPos);
      startLat = cur_location.getLatitude();
      startLon = cur_location.getLongitude();
      old_location = cur_location;
    }
  }
 @Test
 public void testDaysAgo() {
   DateCriterion criterion = new DateCriterion().setDate(3);
   Date date = criterion.getDate();
   assertThat(date.getMinutes(), is(0));
   assertThat(date.getHours(), is(0));
   assertThat(DateUtils.isSameDay(date, DateUtils.addDays(new Date(), -3)), is(true));
 }
Beispiel #25
0
    /**
     * set up urgency adapter and picks the right selected item
     *
     * @param dueDate
     */
    private void createUrgencyList(long dueDate) {
      // set up base urgency list
      String[] labels = getResources().getStringArray(R.array.TEA_urgency);
      UrgencyValue[] urgencyValues = new UrgencyValue[labels.length];
      urgencyValues[0] = new UrgencyValue(labels[0], Task.URGENCY_SPECIFIC_DAY_TIME, SPECIFIC_DATE);
      urgencyValues[1] = new UrgencyValue(labels[1], Task.URGENCY_TODAY);
      urgencyValues[2] = new UrgencyValue(labels[2], Task.URGENCY_TOMORROW);
      String dayAfterTomorrow =
          DateUtils.getDayOfWeekString(
              new Date(DateUtilities.now() + 2 * DateUtilities.ONE_DAY).getDay() + Calendar.SUNDAY,
              DateUtils.LENGTH_LONG);
      urgencyValues[3] = new UrgencyValue(dayAfterTomorrow, Task.URGENCY_DAY_AFTER);
      urgencyValues[4] = new UrgencyValue(labels[4], Task.URGENCY_NEXT_WEEK);
      urgencyValues[5] = new UrgencyValue(labels[5], Task.URGENCY_NONE);

      // search for setting
      int selection = -1;
      for (int i = 0; i < urgencyValues.length; i++)
        if (urgencyValues[i].dueDate == dueDate) {
          selection = i;
          if (dueDate > 0) existingDate = dueDate;
          break;
        }

      if (selection == -1) {
        UrgencyValue[] updated = new UrgencyValue[labels.length + 1];
        for (int i = 0; i < labels.length; i++) updated[i + 1] = urgencyValues[i];
        if (Task.hasDueTime(dueDate)) {
          Date dueDateAsDate = new Date(dueDate);
          updated[0] =
              new UrgencyValue(
                  DateUtilities.getDateStringWithTime(TaskEditActivity.this, dueDateAsDate),
                  Task.URGENCY_SPECIFIC_DAY_TIME,
                  dueDate);
          existingDate = dueDate;
          existingDateHour = dueDateAsDate.getHours();
          existingDateMinutes = dueDateAsDate.getMinutes();
        } else {
          updated[0] =
              new UrgencyValue(
                  DateUtilities.getDateString(TaskEditActivity.this, new Date(dueDate)),
                  Task.URGENCY_SPECIFIC_DAY,
                  dueDate);
          existingDate = dueDate;
          existingDateHour = SPECIFIC_DATE;
        }
        selection = 0;
        urgencyValues = updated;
      }

      urgencyAdapter =
          new ArrayAdapter<UrgencyValue>(
              TaskEditActivity.this, android.R.layout.simple_spinner_item, urgencyValues);
      urgencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      this.spinner.setAdapter(urgencyAdapter);
      this.spinner.setSelection(selection);
    }
Beispiel #26
0
 private void init_suivi() {
   Date s = new Date(new Date().getTime());
   String str = "";
   str += s.getDate() + "-";
   str += s.getMonth() + "-";
   str += s.getYear() + "- (";
   str += s.getHours() + ":";
   str += s.getMinutes() + ")";
   suivis.add(new Suivi(str, "Pas de Probleme"));
 }
Beispiel #27
0
 @SuppressWarnings("deprecation")
 public Object transform(Object o) {
   if (o instanceof TestDate) {
     TestDate td = (TestDate) o;
     return new java.util.Date(td.year, td.month, td.date, td.hour, td.minute, td.second);
   } else if (o instanceof java.util.Date) {
     Date d = (Date) o;
     return new TestDate(
         d.getYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
   } else return o;
 }
Beispiel #28
0
  public static void main(String[] args) throws InterruptedException, IOException {

    SocketInterface sock = new LinuxSocketInterface("mon0", "@aircrack");
    sock.open();

    while (true) {

      byte buf[] = sock.getEncoder().getBuffer().data;
      for (int i = 0; i < buf.length; i++) buf[i] = 0;

      Beacon beacon = sock.getEncoder().getBeacon();

      // System.out.println(sock.getEncoder().getBuffer().toHex(256));

      beacon.getDA().set("ff:ff:ff:ff:ff:ff");
      beacon.getSA().set("12:34:56:78:9a:bc");
      beacon.getBSSID().set("12:34:56:78:9a:bc");

      beacon.setBeaconInterval(100);

      beacon.getCapability().setCfPollRequest(true);
      beacon.getCapability().setChannelAgility(true);
      beacon.getCapability().setDsssOfdm(true);

      Date now = new Date();
      String ssid = String.format("%02d:%02d", now.getHours(), now.getMinutes());

      beacon
          .getInformationList()
          .addInformationElement(InformationElementId.SSID, ssid.getBytes("UTF-8"));
      beacon
          .getInformationList()
          .addInformationElement(
              InformationElementId.SupportedRates,
              new byte[] {(byte) 0x82, (byte) 0x84, (byte) 0x8b, (byte) 0x96});

      //			System.out.println("Buffer Size: " + beacon.getBuffer().size);
      //			System.out.println("Buffer Offset: " + beacon.getInformationList().getOffset());
      //			System.out.println("Count: " + beacon.getInformationList().count());
      //			System.out.println(sock.getEncoder().getBuffer().toHex(63));

      //			beacon.setAddress1(address);
      //			beacon.setSA(iface.getMac());
      //			beacon.setBSSID(iface.getMac());
      //			beacon.setBeaconInterval(100);
      //			beacon.capability.cfPollRequest = true;
      //			beacon.capability.channelAgility = true;
      //			beacon.capability.dsssOfdm = true;
      //
      Thread.sleep(10);

      sock.send(beacon);
    }
  }
Beispiel #29
0
  /** set Nce clock and start clock */
  @SuppressWarnings("deprecation")
  public void startHardwareClock(Date now) {
    if (DEBUG_SHOW_PUBLIC_CALLS && log.isDebugEnabled()) {
      log.debug("startHardwareClock: " + now);
    }
    if (!internalClock.getInternalMaster()
        && internalClock.getMasterName().equals(getHardwareClockName())) {}

    issueClockSet(now.getHours(), now.getMinutes(), now.getSeconds());
    issueClockStart();
  }
 private void mergeDates(Task remote, Task local) {
   if (remote.hasDueDate() && local.hasDueTime()) {
     Date newDate = new Date(remote.getValue(Task.DUE_DATE));
     Date oldDate = new Date(local.getValue(Task.DUE_DATE));
     newDate.setHours(oldDate.getHours());
     newDate.setMinutes(oldDate.getMinutes());
     newDate.setSeconds(oldDate.getSeconds());
     long setDate = Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, newDate.getTime());
     remote.setValue(Task.DUE_DATE, setDate);
   }
 }