/**
   * Erstellt eine neue Buchung
   *
   * @param roomTag: der Raumtyp als String
   * @param location: der Standort als String
   * @param bookedFrom: das Startdatum als String
   * @param bookedTil: das Enddatum als String
   * @param user: die Id des Nutzers als int
   */
  public void newBooking(
      final String bookedFrom,
      final String bookedTil,
      final int user,
      final String location,
      final String roomTag,
      final List<String> material_zur_buchung) {

    String transF[] = bookedFrom.split("T", 2);
    String bookF = transF[0] + " " + transF[1] + ":00";

    Timestamp dateFrom = Timestamp.valueOf(bookF);

    String transT[] = bookedTil.split("T", 2);
    String bookT = transT[0] + " " + transT[1] + ":00";

    Timestamp dateTo = Timestamp.valueOf(bookT);

    Standort standort = this.standRepo.getStandort(location);

    Room room = this.roomRepo.getRoom(roomTag, location);

    User userObj = this.userRepository.getUserById(user);

    bookingRepository.newBooking(dateFrom, dateTo, userObj, standort, room, null, null);
  }
  public static ArrayList<Entry> getUnsyncEntries(int pid, String username, User user)
      throws JSONException {
    ArrayList<Entry> entries = new ArrayList<Entry>();
    final String PREF_NAME = "u: " + username + " " + pid;
    Preferences prefs = Preferences.userNodeForPackage(Synchronisatie.class);
    String json = prefs.get(PREF_NAME, "Geen entries");

    JSONObject project = new JSONObject(json);

    JSONArray entryArray = project.optJSONArray("entries");

    for (int i = 0; i < entryArray.length(); i++) {
      JSONObject entryJson = entryArray.getJSONObject(i);

      String desc = entryJson.getString("notities");
      String begin = entryJson.getString("begin");
      String eind = entryJson.getString("eind");

      System.out.println(eind);

      Date start = Timestamp.valueOf(begin);
      Date end;
      if (eind.equals("0000-00-00 00:00:00")) {
        end = null;
      } else {
        end = Timestamp.valueOf(eind);
      }

      Entry entry = new Entry(start, end, desc, user, pid);
      entry.entryid = "-1";
      entries.add(entry);
    }

    return entries;
  }
  private Set<Contributor> theContributors() {
    try {
      Set<Contributor> contributors = new HashSet<Contributor>(3);
      Contributor contributor = new Contributor();
      contributor.setId("ff808081369cf58901369cf88a3d0003");
      contributor.setUserId(1);
      contributor.setLastVisit(null);
      contributor.setLastValidation(null);
      contributors.add(contributor);

      contributor = new Contributor();
      contributor.setId("f808081369cf58901369cf88a3d0004");
      contributor.setUserId(2);
      contributor.setLastVisit(Timestamp.valueOf("2012-04-10 17:57:08.8"));
      contributor.setLastValidation(Timestamp.valueOf("2012-04-10 17:57:08.818"));
      contributors.add(contributor);

      contributor = new Contributor();
      contributor.setId("ff808081369cf58901369cf88a3d0005");
      contributor.setUserId(0);
      contributor.setLastVisit(Timestamp.valueOf("2012-04-10 17:56:46.549"));
      contributor.setLastValidation(Timestamp.valueOf("2012-04-10 17:56:46.574"));
      contributors.add(contributor);

      return contributors;
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
  @Action(
      value = "/AddMeet",
      results = {@Result(name = "show", location = "/index.jsp")})
  public String add() {
    // System.out.println("addmeet"+memps);

    // System.out.println(mname+"#"+rid+"#"+mnumber+"#"+startdate+starttime+"#"+enddate+"#"+mremark+"#"+memps);

    String mstarttime = startdate + " " + starttime + ":00";
    String mendtime = enddate + " " + endtime + ":00";
    Timestamp mstarttimes = Timestamp.valueOf(mstarttime);
    Timestamp mendtimes = Timestamp.valueOf(mendtime);
    Timestamp appointtime = new Timestamp(System.currentTimeMillis());
    String ename = (String) ActionContext.getContext().getSession().get("ename");
    System.out.println(ename + "li");
    List<Emp> emps = empService.getByEname(ename);
    Emp emp = emps.get(0);
    Room room = roomService.getByIdRoom(rid);
    Meet meet =
        new Meet(mname, emp, room, mnumber, mstarttimes, mendtimes, appointtime, mremark, memps, 1);
    // System.out.println(meet.toString());
    meetService.addMeet(meet);

    meetlist = meetService.getAllMeet();

    return "show";
  }
  @Test
  @WithMockUser(roles = "Tutor")
  public void currentMonthBalanceMultipleAppointments() throws Exception {
    Appointment testAppointment1 = new Appointment();
    Appointment testAppointment2 = new Appointment();

    LocalDateTime dateTime = LocalDateTime.now();

    testAppointment1.setAvailability(Availability.ARRANGED);
    testAppointment1.setTutor(TestUtility.testUser);
    testAppointment1.setStudent(TestUtility.testUserTwo);
    testAppointment1.setWage(BigDecimal.TEN);
    testAppointment1.setDay(dateTime.getDayOfWeek());
    testAppointment1.setTimestamp(Timestamp.valueOf(dateTime));

    appointmentDao.save(testAppointment1);

    testAppointment2.setAvailability(Availability.ARRANGED);
    testAppointment2.setTutor(TestUtility.testUser);
    testAppointment2.setStudent(TestUtility.testUserTwo);
    testAppointment2.setWage(BigDecimal.TEN);
    testAppointment2.setDay(dateTime.getDayOfWeek());
    testAppointment2.setTimestamp(Timestamp.valueOf(dateTime.minusHours(1)));

    appointmentDao.save(testAppointment2);

    BigDecimal reference = BigDecimal.TEN.multiply(ConstantVariables.PERCENTAGE);
    reference = reference.add(BigDecimal.TEN.multiply(ConstantVariables.PERCENTAGE));

    mockMvc
        .perform(get("/bill").principal(this.authUser))
        .andExpect(model().attribute("balance", reference.setScale(2)));
  }
Beispiel #6
0
 private int searchCompare(Note n1, Note n2) {
   Integer count1 = Integer.valueOf(n1.getCount());
   Integer count2 = Integer.valueOf(n2.getCount());
   Date date1 = new Date((Timestamp.valueOf(n1.getDateTime())).getTime());
   Date date2 = new Date((Timestamp.valueOf(n2.getDateTime())).getTime());
   Integer type1 = Integer.valueOf(n1.getType());
   Integer type2 = Integer.valueOf(n2.getType());
   Integer imp1 = Integer.valueOf(n1.getImportant());
   Integer imp2 = Integer.valueOf(n2.getImportant());
   if (count1.equals(count2)) {
     if (n1.getType() == Note.REMINDER && n2.getType() == Note.REMINDER) {
       Date rdate1 = NoteComparator.StringToDate(n1.getRDateTime());
       Date rdate2 = NoteComparator.StringToDate(n1.getRDateTime());
       if (rdate1.equals(rdate2)) {
         return imp2.compareTo(imp1);
       }
       return rdate2.compareTo(rdate1);
     }
     if (type1.equals(type2)) {
       if (date1.equals(date2)) {
         return imp2.compareTo(imp1);
       }
       return date2.compareTo(date1);
     }
     return type2.compareTo(type1);
   }
   return count2.compareTo(count1);
 }
Beispiel #7
0
  /** 通过活动类型获取时间进行比较 */
  public String judgeNameRepeat() {
    try {
      HttpServletRequest request = ServletActionContext.getRequest();
      HttpServletResponse response = ServletActionContext.getResponse();
      request.setCharacterEncoding("UTF-8");
      response.setCharacterEncoding("UTF-8");

      // 获取活动类型 开始时间 结束时间
      String caseName = request.getParameter("caseName");
      String caseStime = request.getParameter("caseSt");
      String caseEtime = request.getParameter("caseEt");

      // 转化为dateTime
      Timestamp startTime = Timestamp.valueOf(caseStime);
      Timestamp endTime = Timestamp.valueOf(caseEtime);

      int spaceTime = paraDtService.getCaseNameTime(caseName, startTime, endTime);
      if (spaceTime > 0) {
        flag = true;
      } else if (spaceTime == 0) {
        flag = false;
      }
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return SUCCESS;
  }
Beispiel #8
0
 @Test
 public void testGetTimestamp() throws Exception {
   List<Query.Type> types = Arrays.asList(Query.Type.DATETIME, Query.Type.TIMESTAMP);
   for (Query.Type type : types) {
     try (Cursor cursor =
         new SimpleCursor(
             QueryResult.newBuilder()
                 .addFields(Field.newBuilder().setName("col1").setType(type).build())
                 .addFields(Field.newBuilder().setName("null").setType(type).build())
                 .addRows(
                     Query.Row.newBuilder()
                         .addLengths("2008-01-02 14:15:16.123456".length())
                         .addLengths(-1) // SQL NULL
                         .setValues(ByteString.copyFromUtf8("2008-01-02 14:15:16.123456")))
                 .build())) {
       Row row = cursor.next();
       Assert.assertNotNull(row);
       Assert.assertEquals(Timestamp.valueOf("2008-01-02 14:15:16.123456"), row.getObject("col1"));
       Assert.assertEquals(
           Timestamp.valueOf("2008-01-02 14:15:16.123456"), row.getTimestamp("col1"));
       Timestamp ts = new Timestamp(1199283316000L);
       ts.setNanos(123456000);
       Assert.assertEquals(ts, row.getTimestamp("col1", GMT));
       Assert.assertFalse(row.wasNull());
       Assert.assertEquals(null, row.getTimestamp("null"));
       Assert.assertTrue(row.wasNull());
     }
   }
 }
  private void horaAdicional() {
    SimpleDateFormat formatTimeStamp;
    formatTimeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      HSAsistenciaDocenteDAO dao =
          (HSAsistenciaDocenteDAO) ServiceFinder.findBean("SpringHibernateDaoAsistenciaDocente");

      AcSesionAsistencia sesasis = new AcSesionAsistencia();
      // this.getNuevAsisDocente().getN_curso_seccion()
      sesasis.setAcSeccion(new AcSeccion(nuevaHoraAdicional.getIdSec()));
      sesasis.setSesFechaSesion(nuevaHoraAdicional.getN_fsesion());
      sesasis.setSesFechaRegistro(nuevaHoraAdicional.getN_fsesion());
      sesasis.setSesFechaInicio(
          Timestamp.valueOf(formatTimeStamp.format(nuevaHoraAdicional.getN_fsesion_ini())));
      sesasis.setSesFechaFin(
          Timestamp.valueOf(formatTimeStamp.format(nuevaHoraAdicional.getN_fsesion_fin())));
      sesasis.setSesActivo("1");
      sesasis.setSesTimeTolerancia(20);
      sesasis.setSesTimeAntes(20);
      sesasis.setSesTimeTope(30);
      sesasis.setAulId(0);
      sesasis.setSesEstado("044001");
      sesasis.setSesFechaSalida(10);
      sesasis.setDocId(nuevaHoraAdicional.getN_doc_id());
      sesasis.setDocIdBk(nuevaHoraAdicional.getN_doc_id());
      sesasis.setSesTipo(nuevaHoraAdicional.getN_tipses_code());
      sesasis.setSesTipoAsistencia(ConstantesWeb.COD_SES_ASIST_CL);
      sesasis.setSesObservacion("");
      sesasis.setSesEstadoDocTipo("046001");

      dao.ingresarSesionAsistencia(sesasis);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Test
  public void levelUpWeekend() {

    LevelUpCampaign campaign = new LevelUpCampaign(100, CampaignState.ACTIVE);
    Timestamp executionTime = Timestamp.valueOf("2016-01-21 00:00:00");

    String message = campaign.testFailCalendarRestriction(null, executionTime, true);
    System.out.println("Got message: " + message);

    assertNotNull(message);

    executionTime = Timestamp.valueOf("2016-01-22 00:00:00");

    message = campaign.testFailCalendarRestriction(null, executionTime, true);
    System.out.println("Got message: " + message);

    assertNotNull(message);

    executionTime = Timestamp.valueOf("2016-01-23 00:00:00");

    message = campaign.testFailCalendarRestriction(null, executionTime, true);
    System.out.println("Got message: " + message);

    assertThat(message, is((String) null));
  }
  public ArrayList<CallDuration> search_user_calls(int name) {
    System.out.println("15. search_user_calls (\\/)");
    String sql = "SELECT * FROM call WHERE caller = " + name + " ;";
    ArrayList<CallDuration> call_list = new ArrayList<CallDuration>();
    ResultSet rs;
    rs = do_query(connection, sql);

    try {
      while (rs.next()) {
        CallDuration new_call =
            new CallDuration(
                rs.getInt("call_id"),
                rs.getInt("callers_prog"),
                Timestamp.valueOf(rs.getString("start")),
                Timestamp.valueOf(rs.getString("end")));
        call_list.add(new_call);
      }
      close_resultset(rs);
      return call_list;
    } catch (SQLException e) {
      e.printStackTrace();
      close_resultset(rs);
      return call_list;
    }
  }
  public boolean getEntries(User u, JFrame frame) {
    if (!Methodes.testConnectie()) {
      JFrame[] frames = {frame};
      Methodes.Disconnect(frames, "Connectie verloren, terug naar login scherm");
    }
    boolean check = false;

    DefaultHttpClient client = u.getClient();
    HttpGet getRequest =
        new HttpGet("http://" + Methodes.getIp() + "/webservice/getProjectById/" + id);
    try {
      HttpResponse resp = client.execute(getRequest);
      // Date start, Date end, String description,Project p
      BufferedReader rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
      String output = "";
      boolean oneLoop = true;
      while ((output = rd.readLine()) != null) {
        if (oneLoop) {
          Synchronisatie.setOfflineEntries(this.id, output, this.user.username);
        }
        oneLoop = false;
        System.out.println(output);
        JSONObject jsonObject = new JSONObject(output);
        JSONArray array = jsonObject.optJSONArray("entries");
        for (int i = 0; i < array.length(); i++) {
          JSONObject entry = (JSONObject) array.get(i);
          String description = entry.getString("notities");
          String name = entry.getString("achternaam");
          String firstname = entry.getString("voornaam");

          String begin = entry.getString("begin");
          String eind = entry.getString("eind");

          System.out.println(eind);

          Date start = Timestamp.valueOf(begin);
          Date end;
          if (eind.equals("0000-00-00 00:00:00")) {
            end = null;
          } else {

            end = Timestamp.valueOf(eind);
          }
          int uid = entry.getInt("uid");
          String trid = entry.getString("trid");
          // int rid = entry.getInt("rid");
          if (entries.add(new Entry(start, end, description, u, this.id, trid))) check = true;
          // System.out.println(new Entry(start,end,description,this,new User(uid,firstname,name)));

        }
      }

    } catch (IOException | JSONException e) {
      e.printStackTrace();
    } finally {
      client.getConnectionManager().shutdown();
    }
    return check;
  }
  /** Test of setObject method, of inteface java.sql.CallableStatement. */
  public void testSetObject_TIMESTAMP() throws Exception {
    println("setObject - TIMESTAMP");

    setUpDualTable();

    setObjectTest("timestamp(6)", Timestamp.valueOf("2005-12-13 01:23:47.123456"), Types.TIMESTAMP);

    setObjectTest("timestamp(0)", Timestamp.valueOf("2005-12-13 01:23:47"), Types.TIMESTAMP);
  }
Beispiel #14
0
 public void fetchBroadcast(Timestamp paramTimestamp) throws Exception {
   ResultSet localResultSet = null;
   Connection localConnection = getConnection();
   Statement localStatement = null;
   PreparedStatement localPreparedStatement = null;
   try {
     this.newestUpdateTime = null;
     this.currentDbTime = null;
     localStatement = localConnection.createStatement();
     localResultSet = localStatement.executeQuery("select sysdate from dual");
     if (localResultSet.next()) {
       this.currentDbTime = localResultSet.getTimestamp("sysdate");
     }
     localResultSet.close();
     localStatement.close();
     String str = null;
     localPreparedStatement = null;
     if (paramTimestamp == null) {
       str =
           "select ID, title, author, type, sendtime, endtime, createtime, updatetime from v_broadcast where type = 1 order by updatetime desc";
       localPreparedStatement = localConnection.prepareStatement(str);
     } else {
       str =
           "select ID, title, author, type, sendtime, endtime, createtime, updatetime from v_broadcast where type = 1 and updatetime > ? order by updatetime desc";
       localPreparedStatement = localConnection.prepareStatement(str);
       localPreparedStatement.setTimestamp(1, paramTimestamp);
     }
     localResultSet = localPreparedStatement.executeQuery();
     this.newestBroadcastTitleList = new ArrayList();
     while (localResultSet.next()) {
       if ((this.newestUpdateTime == null)
           || (localResultSet.getTimestamp("updatetime").compareTo(this.newestUpdateTime) > 0)) {
         this.newestUpdateTime = localResultSet.getTimestamp("updatetime");
       }
       Broadcast localBroadcast = new Broadcast();
       localBroadcast.setAuthor(
           localResultSet.getString("author") == null ? "" : localResultSet.getString("author"));
       localBroadcast.setCreatetime(localResultSet.getTimestamp("createtime"));
       localBroadcast.setId(new Long(localResultSet.getLong("id")));
       localBroadcast.setTitle(localResultSet.getString("title"));
       localBroadcast.setType(
           localResultSet.getString("type") == null ? "" : localResultSet.getString("type"));
       localBroadcast.setUpdatetime(localResultSet.getTimestamp("updatetime"));
       localBroadcast.setSendtime(Timestamp.valueOf("1901-01-01 00:00:00.0"));
       localBroadcast.setEndtime(Timestamp.valueOf("2999-12-01 00:00:00.0"));
       this.newestBroadcastTitleList.add(localBroadcast);
     }
   } catch (Exception localException) {
     throw localException;
   } finally {
     closeResultSet(localResultSet);
     closeStatement(localStatement);
     closeStatement(localPreparedStatement);
     closeConnection(localConnection);
   }
 }
 @Test
 public void testCompare() throws Exception {
   ValueMetaTimestamp vm = new ValueMetaTimestamp();
   Timestamp earlier = Timestamp.valueOf("2012-12-12 12:12:12.121212");
   Timestamp later = Timestamp.valueOf("2013-12-12 12:12:12.121212");
   assertEquals(vm.compare(null, null), 0);
   assertEquals(vm.compare(null, earlier), -1);
   assertEquals(vm.compare(earlier, null), 1);
   assertEquals(vm.compare(earlier, earlier), 0);
   assertEquals(vm.compare(earlier, later), -1);
   assertEquals(vm.compare(later, earlier), 1);
 }
 @Test
 public void testConvertStringToTimestamp() throws Exception {
   ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp();
   assertEquals(
       Timestamp.valueOf("2012-04-05 04:03:02.123456"),
       valueMetaTimestamp.convertStringToTimestamp("2012/4/5 04:03:02.123456"));
   assertEquals(
       Timestamp.valueOf("2012-04-05 04:03:02.123"),
       valueMetaTimestamp.convertStringToTimestamp("2012/4/5 04:03:02.123"));
   assertEquals(
       Timestamp.valueOf("2012-04-05 04:03:02.123456789"),
       valueMetaTimestamp.convertStringToTimestamp("2012/4/5 04:03:02.123456789"));
 }
  @Test
  public void registerEvents() {

    Agent item1 = new Agent("item1");
    entityManager.persist(item1);
    Agent item2 = new Agent("item2");
    entityManager.persist(item2);
    Agent item3 = new Agent("item3");
    entityManager.persist(item3);
    Agent item4 = new Agent("item4");
    entityManager.persist(item4);

    eventManager.registerEvent(
        "event1",
        Timestamp.valueOf("2010-01-01 10:00:00.0"),
        item1.getKey(),
        item2.getKey(),
        item3.getKey(),
        item4.getKey());

    eventManager.registerEvent(
        "event2", Timestamp.valueOf("2010-01-02 10:00:00.0"), item1.getKey(), item4.getKey());

    eventManager.registerEvent(
        "event3", Timestamp.valueOf("2010-01-05 10:00:00.0"), item2.getKey(), item4.getKey());

    // List<Event> eventsItem1 =
    // eventManager.findEventsForItemBetween(item1.getKey(), Timestamp
    // .valueOf("2010-01-01 00:00:00.0"),
    // Timestamp.valueOf("2010-01-10 00:00:00.0"));
    // assertEquals(2, eventsItem1.size());
    //
    // List<Event> eventsItem2 =
    // eventManager.findEventsForItemBetween(item2.getKey(), Timestamp
    // .valueOf("2010-01-01 00:00:00.0"),
    // Timestamp.valueOf("2010-01-10 00:00:00.0"));
    // assertEquals(2, eventsItem2.size());
    //
    // List<Event> eventsItem3 =
    // eventManager.findEventsForItemBetween(item3.getKey(), Timestamp
    // .valueOf("2010-01-01 00:00:00.0"),
    // Timestamp.valueOf("2010-01-10 00:00:00.0"));
    // assertEquals(1, eventsItem3.size());
    //
    // List<Event> eventsItem4 =
    // eventManager.findEventsForItemBetween(item4.getKey(), Timestamp
    // .valueOf("2010-01-01 00:00:00.0"),
    // Timestamp.valueOf("2010-01-10 00:00:00.0"));
    // assertEquals(3, eventsItem4.size());

  }
 @Test
 public void testConvertTimestampToString() throws Exception {
   ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp();
   assertEquals(
       "2012/04/05 04:03:02.123456000",
       valueMetaTimestamp.convertTimestampToString(
           Timestamp.valueOf("2012-04-05 04:03:02.123456")));
   assertEquals(
       "2012/04/05 04:03:02.123000000",
       valueMetaTimestamp.convertTimestampToString(Timestamp.valueOf("2012-04-05 04:03:02.123")));
   assertEquals(
       "2012/04/05 04:03:02.123456789",
       valueMetaTimestamp.convertTimestampToString(
           Timestamp.valueOf("2012-04-05 04:03:02.123456789")));
 }
  /** Test of setTimestamp method, of inteface java.sql.CallableStatement. */
  public void testSetTimestamp() throws Exception {
    println("setTimestamp");

    setUpDualTable();
    prepareCall("select cast(? as timestamp) from dual")
        .setTimestamp("@p1", Timestamp.valueOf("2005-12-13 11:23:02.1234"));
  }
  public Vector<QuestionSheet> parseGetSheetsResponse(String jsonInputString) {

    Vector<QuestionSheet> questionSheets = new Vector<QuestionSheet>();

    try {
      JSONObject jsonObject = new JSONObject(jsonInputString);

      JSONArray questionSheetArray = jsonObject.getJSONArray("questionSheets");

      for (int i = 0; i < questionSheetArray.length(); i++) {
        QuestionSheet questionSheet = new QuestionSheet();

        JSONObject questionSheetJsonObject = questionSheetArray.getJSONObject(i);

        questionSheet.setName(questionSheetJsonObject.getString("name"));
        questionSheet.setCreate_date(
            Timestamp.valueOf(questionSheetJsonObject.getString("create_date")));
        questionSheet.setID(Integer.valueOf(questionSheetJsonObject.getString("ID")));

        questionSheets.addElement(questionSheet);
      }
    } catch (JSONException e) {
      Log.i("SASH", "couldn't parse getSheets-response");
      e.printStackTrace();
    }

    return questionSheets;
  }
Beispiel #21
0
 private void setComparableValue(String s) throws Exception {
   if (NULL.equalsIgnoreCase(s) && !IS_NULL.equalsIgnoreCase(this.type))
     throw new BadComparisonException(
         "Use condition type=\"isNull\" for comparisons to null values");
   try {
     if (propertyClass == null || propertyClass.length() < 1) {
       targetValue = s;
     } else {
       Class c = Class.forName(propertyClass);
       if ("today".equalsIgnoreCase(s)
           && (c.equals(java.sql.Date.class)
               || c.equals(java.sql.Timestamp.class)
               || c.equals(java.sql.Date.class))) targetValue = s;
       else if (c.equals(java.sql.Date.class)) targetValue = javaUtilDateFormatter.parse(s);
       else if (c.equals(java.sql.Timestamp.class))
         targetValue = new java.sql.Date(Long.parseLong(s));
       else if (c.equals(java.util.Date.class)) targetValue = java.sql.Timestamp.valueOf(s);
       else if (c.equals(Boolean.class)) targetValue = Boolean.valueOf(s);
       else if (c.equals(Double.class)) targetValue = Double.parseDouble(s);
       else if (c.equals(Float.class)) targetValue = Float.parseFloat(s);
       else if (c.equals(Long.class)) targetValue = Long.parseLong(s);
       else if (c.equals(Integer.class)) targetValue = Integer.parseInt(s);
       else targetValue = s;
     }
   } catch (Exception e) {
     logger.debug(
         "Error setting condition target value to " + s + " which is a " + propertyClass, e);
     throw e;
   }
 }
 public Project(String naam, String klant, String start, String descriptie, String id) {
   this.projectName = naam;
   this.customer = klant;
   this.startDate = Timestamp.valueOf(start);
   this.description = descriptie;
   this.id = Integer.parseInt(id);
 }
Beispiel #23
0
  /** 添加活动信息 */
  public String savePCD() {
    HttpServletRequest request = ServletActionContext.getRequest();
    Date date = new Date(); // 创建一个时间对象,获取到当前的时间
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置时间显示格式
    String str = sdf.format(date); // 将当前时间格式化为需要的类型

    // 封装数据
    paraDt.setCaseName(paraCaseP.getCaseName());
    paraDt.setCaseCode(paraCaseP.getCaseCode());
    paraDt.setStatus(2);
    paraDt.setSysDt(Timestamp.valueOf(str));
    paraDt.setSysUserId(ParaDtAction.getCurrentUserName());

    // 判断选款数
    // int styleNum=paraDt.getNum();
    if (paraDt.getNum() != 0) {
      paraDtService.saveParaDt(paraDt);
    } else {
      paraDt.setNum(paraCaseP.getNum());
      paraDtService.saveParaDt(paraDt);
    }

    // 添加成功后,管理后台程序通知 BI系统执行活动选款。
    util.callPRtCase(paraDt.getCaseCode(), paraDt.getCaseId());

    HttpSession session = request.getSession(false);
    String caseName = paraCaseP.getCaseName();

    refreshList = "paraCaseDtgetParaDtAll";
    titleName = "营销活动实例";
    msg = " [" + caseName + "] ";
    session.setAttribute("msg", msg);

    return "savePCDSucceed";
  }
Beispiel #24
0
 @Override
 public Data valueOf(String c) {
   if (c == null || c.equals("null")) {
     return new TimestampData(null, this);
   }
   return new TimestampData(Timestamp.valueOf(c), this);
 }
Beispiel #25
0
 public static Timestamp getRandTimestamp(Random r) {
   String optionalNanos = "";
   if (r.nextInt(2) == 1) {
     optionalNanos =
         String.format(".%09d", Integer.valueOf(0 + r.nextInt((int) NANOSECONDS_PER_SECOND)));
   }
   String timestampStr =
       String.format(
           "%04d-%02d-%02d %02d:%02d:%02d%s",
           Integer.valueOf(0 + r.nextInt(10000)), // year
           Integer.valueOf(1 + r.nextInt(12)), // month
           Integer.valueOf(1 + r.nextInt(28)), // day
           Integer.valueOf(0 + r.nextInt(24)), // hour
           Integer.valueOf(0 + r.nextInt(60)), // minute
           Integer.valueOf(0 + r.nextInt(60)), // second
           optionalNanos);
   Timestamp timestampVal;
   try {
     timestampVal = Timestamp.valueOf(timestampStr);
   } catch (Exception e) {
     System.err.println("Timestamp string " + timestampStr + " did not parse");
     throw e;
   }
   return timestampVal;
 }
Beispiel #26
0
    @Test
    public void testInlinedBindValuesForDatetime() throws Exception {
        jOOQAbstractTest.reset = false;

        Date d1 = Date.valueOf("1981-07-10");
        Time t1 = Time.valueOf("12:01:15");
        Timestamp ts1 = Timestamp.valueOf("1981-07-10 12:01:15");

        Factory create = create(new Settings()
            .withStatementType(StatementType.STATIC_STATEMENT));

        DATE date = create.newRecord(TDates());
        date.setValue(TDates_ID(), 1);
        assertEquals(1, date.store());

        date.setValue(TDates_ID(), 2);
        date.setValue(TDates_D(), d1);
        date.setValue(TDates_T(), t1);
        date.setValue(TDates_TS(), ts1);
        assertEquals(1, date.store());

        Result<Record> dates =
        create.select(TDates_ID(), TDates_D(), TDates_T(), TDates_TS())
              .from(TDates())
              .orderBy(TDates_ID())
              .fetch();

        assertEquals(2, dates.size());
        assertEquals(asList(1, 2), dates.getValues(TDates_ID()));
        assertEquals(asList(1, null, null, null), asList(dates.get(0).intoArray()));
        assertEquals(asList((Object) 2, d1, t1, ts1), asList(dates.get(1).intoArray()));
    }
  private DataChunk readSamples(String channelName, Timestamp from) throws Exception {
    DataChunk chunk = new DataChunk(chunkSize);

    BufferedReader br = null;
    String currentLine = "";
    Timestamp lastIndex = indexes.floorKey(from);
    Integer lineToStart = lastIndex == null ? 1 : indexes.get(lastIndex);
    Integer lineNumber = -1;
    try {
      br = new BufferedReader(new FileReader(csvFile));
      while ((currentLine = br.readLine()) != null) {
        lineNumber++;
        if (lineNumber < lineToStart) continue;
        String[] columns = getColumns(currentLine);
        if (columns[channel_name] != null && columns[channel_name].equals(channelName)) {
          // Get time stamp
          final java.sql.Timestamp stamp = java.sql.Timestamp.valueOf(columns[smpl_time]);
          stamp.setNanos(Integer.valueOf(columns[nanosecs]));
          final Timestamp time = fromSQLTimestamp(stamp);
          if (time.compareTo(from) >= 0) {
            final VType value = decodeValue(columns, time);
            SourceData data = new SourceData(time, value);
            if (!chunk.add(data)) {
              TimeInterval i = chunk.getInterval();
              if (i != null) indexes.put(i.getEnd(), lineNumber);
              break;
            }
          }
        }
      }
    } finally {
      if (br != null) br.close();
    }
    return chunk;
  }
  @Test
  public void test_find_flight() {
    // given
    Timestamp date = Timestamp.valueOf("2012-12-20 16:00:00");

    Flight flight1 = new Flight(date, 200, "praha", "london", 300);
    Flight flight2 = new Flight(date, 150, "praha", "berlin", 350);
    Flight flight3 = new Flight(date, 250, "praha", "paris", 350);
    Flight flight4 = new Flight(date, 700, "london", "tokyo", 250);
    Flight flight5 = new Flight(date, 600, "london", "rio", 300);

    genericDao.save(flight1);
    genericDao.save(flight2);
    genericDao.save(flight3);
    genericDao.save(flight4);
    genericDao.save(flight5);

    // when
    List<Flight> retrived = bookingService.findFlight("praha", "paris");
    List<Flight> empty = bookingService.findFlight("praha", "jupiter");
    List<Flight> withtime =
        bookingService.findFlightWithTime("london", "rio", "2012-12-20 16:00:00");

    // then
    assertFalse(retrived.isEmpty());
    assertEquals(flight3, retrived.get(0));
    assertTrue(empty.isEmpty());
    assertFalse(withtime.isEmpty());
    assertEquals(flight5, withtime.get(0));
  }
  @Test
  public void createANewScheduleEvent() throws Exception {
    ScheduleEvent event = new ScheduleEvent();
    event.setAuthor(0);
    event.setCreationDate(Timestamp.valueOf("2012-04-10 17:56:35.761"));
    event.setTitle("A new event");
    event.setDescription("test the persistence of the new event");
    Contributor contributor = new Contributor();
    contributor.setUserId(0);
    contributor.setUserName("Bart Simpson");
    contributor.setScheduleEvent(event);
    event.getContributors().add(contributor);
    scheduleEventDao.createScheduleEvent(event);

    int rowCount =
        databaseTester
            .getConnection()
            .getRowCount("sc_scheduleevent_list", "where id = '" + event.getId() + "'");
    assertThat(rowCount, is(1));
    rowCount =
        databaseTester
            .getConnection()
            .getRowCount(
                "sc_scheduleevent_contributor", "where id = '" + contributor.getId() + "'");
    assertThat(rowCount, is(1));
  }
 public Object deserialize(String data) {
   try {
     return java.sql.Timestamp.valueOf(data);
   } catch (IllegalArgumentException e) {
     throw new JRRuntimeException("Error parsing Timestamp data \"" + data + "\"", e);
   }
 }