List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:com.mothsoft.alexis.engine.numeric.CorrelationCalculatorTest.java
@Before public void setUp() { this.dao = mock(DataSetPointDao.class); this.calculator = new CorrelationCalculatorImpl(this.dao); final Long millis = System.currentTimeMillis(); this.now = new Timestamp(millis); this.yesterday = new Timestamp(millis - DateConstants.ONE_DAY_IN_MILLISECONDS); this.yesterdayPlus2Hours = new Timestamp(millis + (2 * 60 * 60 * 1000)); this.yesterdayPlus3Hours = new Timestamp(millis + (3 * 60 * 60 * 1000)); this.yesterdayPlus4Hours = new Timestamp(millis + (4 * 60 * 60 * 1000)); this.yesterdayPlus5Hours = new Timestamp(millis + (5 * 60 * 60 * 1000)); this.ds1 = mock(DataSet.class); when(this.ds1.getId()).thenReturn(1L); this.ds2 = mock(DataSet.class); when(this.ds2.getId()).thenReturn(2L); }
From source file:org.uaa.security.core.LoggerManager.java
public void logAfter(HttpServletRequest request) { if (res_uri.startsWith("/logs")) return;/*from w ww.ja v a 2 s . com*/ response_time = new Timestamp(System.currentTimeMillis()); log.setResponse_time(response_time.getTime()); log.setTime(response_time.getTime() - request_time.getTime()); if (SecurityContextHolder.getContext().getAuthenticationToken() != null) { Integer uid = SecurityContextHolder.getContext().getAuthenticationToken().getUid(); log.setUid(uid); } securityService.updateLog(log); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.DumpTestController.java
@Override protected ResponseValues processRequest(VitroRequest vreq) { Map<String, Object> body = new HashMap<String, Object>(); body.put("title", "Freemarker Test"); body.put("dog", "Rover"); body.put("int", 7); body.put("bool", false); body.put("now", new Date()); java.sql.Date date = new java.sql.Date(1302297332043L); body.put("date", date); Time time = new Time(1302297332043L); body.put("time", time); Timestamp ts = new Timestamp(1302297332043L); body.put("timestamp", ts); // List of strings List<String> fruit = new ArrayList<String>(); fruit.add("apples"); fruit.add("bananas"); fruit.add("peaches"); body.put("fruit", fruit); // Mixed list List<Object> mixedList = new ArrayList<Object>(); String myString = "apples"; mixedList.add(myString);/*from w w w . j av a2 s . c om*/ int myInt = 4; mixedList.add(myInt); boolean myBool = true; mixedList.add(myBool); List<String> myList = new ArrayList<String>(); myList.add("dog"); myList.add("cat"); myList.add("elephant"); mixedList.add(myList); body.put("mixedList", mixedList); // Collection (non-indexable) Set<Integer> odds = new HashSet<Integer>(); for (int i = 0; i <= 10; i++) { if (i % 2 == 1) { odds.add(i); } } body.put("oddNums", new SimpleCollection(odds)); // String-string map Map<String, String> myMap = new HashMap<String, String>(); myMap.put("Albany", "New York"); myMap.put("St. Paul", "Minnesota"); myMap.put("Austin", "Texas"); myMap.put("Sacramento", "California"); myMap.put("Richmond", "Virginia"); body.put("capitals", myMap); // Mixed map Map<String, Object> mixedMap = new HashMap<String, Object>(); mixedMap.put("myString", myString); mixedMap.put("myBoolean", myBool); mixedMap.put("myNumber", myInt); Date myDate = new Date(); mixedMap.put("myDate", myDate); mixedMap.put("myList", myList); mixedMap.put("capitals", myMap); body.put("mixedMap", mixedMap); // Java object Employee jdoe = getEmployee(); body.put("employeeLimited", jdoe); try { body.put("employeeInvisible", wrap(jdoe, BeansWrapper.EXPOSE_NOTHING)); body.put("employeeFull", wrap(jdoe, BeansWrapper.EXPOSE_SAFE)); } catch (TemplateModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new TemplateResponseValues(TEMPLATE_DEFAULT, body); }
From source file:com.himanshu.um.impl.manager.DatabaseManagerImpl.java
@Override public void addNewUser(User user) throws UserCreationException { com.himanshu.um.impl.user.db.User userDB = new com.himanshu.um.impl.user.db.User(); userDB.setUsername(user.getUsername()); userDB.setPassword(user.getPassword()); userDB.setCreatedDate(new Timestamp(user.getCreatedDate().toGregorianCalendar().getTimeInMillis())); userDB.setStatus(user.isStatus());//from ww w . jav a 2 s .co m userDB.setLastModifiedDate( new Timestamp(user.getLastModifiedDate().toGregorianCalendar().getTimeInMillis())); userDao.save(userDB); }
From source file:org.uaa.admin.resource.Apilogs.java
@Path("/requests") @GET/*from w ww . jav a 2s . c om*/ public String getRequestCount(@QueryParam("interval") Integer interval) { if (interval == null) interval = default_interval; Timestamp now = new Timestamp(System.currentTimeMillis()); Integer count = apilogService.getRequestCount(interval, now.getTime()); Map<String, Object> attrs = new LinkedHashMap<String, Object>(); attrs.put("count", count); ResponseWithData res = new ResponseWithData(attrs); return res.toJson(); }
From source file:de.jlo.talendcomp.json.TypeUtil.java
public static Timestamp convertToTimestamp(String dateString, String pattern) throws Exception { Date date = convertToDate(dateString, pattern); if (date != null) { return new Timestamp(date.getTime()); } else {/* w w w.j a v a2 s . com*/ return null; } }
From source file:mtsar.api.csv.AnswerCSV.java
public static Iterator<Answer> parse(Stage stage, CSVParser csv) { final Set<String> header = csv.getHeaderMap().keySet(); checkArgument(!Sets.intersection(header, Sets.newHashSet(HEADER)).isEmpty(), "Unknown CSV header: %s", String.join(",", header)); return StreamSupport.stream(csv.spliterator(), false).map(row -> { final String id = row.isSet("id") ? row.get("id") : null; final String[] tags = row.isSet("tags") && !StringUtils.isEmpty(row.get("tags")) ? row.get("tags").split("\\|") : new String[0]; final String type = row.isSet("type") ? row.get("type") : null; final String workerId = row.get("worker_id"); final String taskId = row.get("task_id"); final String[] answers = row.isSet("answers") && !StringUtils.isEmpty(row.get("answers")) ? row.get("answers").split("\\|") : new String[0]; final String datetime = row.isSet("datetime") ? row.get("datetime") : null; return new Answer.Builder().setId(StringUtils.isEmpty(id) ? null : Integer.valueOf(id)) .setStage(stage.getId()).addAllTags(Arrays.asList(tags)) .setDateTime(new Timestamp(StringUtils.isEmpty(datetime) ? System.currentTimeMillis() : Long.parseLong(datetime) * 1000L)) .setType(StringUtils.defaultIfEmpty(type, AnswerDAO.ANSWER_TYPE_DEFAULT)) .setWorkerId(Integer.valueOf(workerId)).setTaskId(Integer.valueOf(taskId)) .addAllAnswers(Arrays.asList(answers)).build(); }).iterator();/*from w ww . j a va 2 s. c o m*/ }
From source file:gov.nih.nci.cabig.caaers.service.security.PasswordManagerServiceTest.java
public void testRequestToken() throws Exception { String userName = "user@domain"; user = new User(); user.setTokenTime(new Timestamp(new Date().getTime())); passwordManagerService.setUserRepository(userRepository); expect(userRepository.getUserByLoginName(userName)).andReturn(user).anyTimes(); userRepository.save(user);//from ww w . ja v a 2 s . co m replayMocks(); User returnedUser = passwordManagerService.requestToken(userName); verifyMocks(); assertNotNull(returnedUser); assertNotNull(returnedUser.getToken()); assertTrue(StringUtils.isNotEmpty(returnedUser.getToken())); }
From source file:henu.dao.impl.CaclDaoImpl.java
@Override public boolean createCacl(Cacl cacl) { String sql = "insert into cacl (cid, cname, structure, author, postime) values(?, ?,?,?,?)"; PreparedStatement ps = SqlDB.executePreparedStatement(sql); int result = 0; try {//w ww . j a v a2 s . c o m ps.setLong(1, cacl.getTid()); ps.setString(2, cacl.getName()); ps.setString(3, cacl.getStructure()); ps.setLong(4, cacl.getAuthor()); ps.setTimestamp(5, new Timestamp(System.currentTimeMillis())); result = ps.executeUpdate(); } catch (SQLException ex) { } return result > 0 && recordCaclUser(cacl.getTid(), cacl.getUsers()); }
From source file:outfox.dict.contest.test.InitSingerData.java
@ResponseBody @RequestMapping(value = "/initData") public String initData() { SingerEntity singerEntity = new SingerEntity(); // 10000??/* w w w .ja v a 2 s . com*/ for (int i = 1; i <= 10; i++) { // ???? singerEntity.setUserId(String.valueOf(i)); singerEntity.setName("" + i); singerEntity.setSchool(getRandomSchool()); singerEntity.setAreaName(getRandomCity()); singerEntity.setPhotoUrl("http://p1.music.126.net/aHW-oDNmj4FcuB34vmg4Ng==/2544269906854087.jpg"); singerEntity.setAudioUrl("http://m2.music.126.net/S7r4Uu8mPCwNhvHcfVbtEA==/2029698464885626.mp3"); singerEntity.setAge(18); singerEntity.setSex(false); singerEntity.setMusicName("" + i); singerEntity.setPhone("121221" + i); Timestamp timestamp = new Timestamp(System.currentTimeMillis()); singerEntity.setSingupTime(timestamp); // 1: ? contestDAO.signup(singerEntity); // 2: ?? String content = "{\"id\": " + singerEntity.getId() + ", \"name\": \"" + singerEntity.getName() + "\", \"school\": \"" + singerEntity.getSchool() + "\", \"areaName\": \"" + singerEntity.getAreaName() + "\", \"audioUrl\": \"" + singerEntity.getAudioUrl() + "\"}"; HttpResponse response = null; try { List<NameValuePair> paramsList = new ArrayList<NameValuePair>(); paramsList.add(new BasicNameValuePair("voteId", ContestConsts.VOTE_ID)); paramsList.add(new BasicNameValuePair("content", content)); paramsList.add(new BasicNameValuePair("picture", singerEntity.getPhotoUrl())); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramsList, "UTF-8"); response = HttpToolKit.getInstance().doPost(ContestConsts.ADD_VOTE_OPTION_INTERFACE, entity); } catch (Exception e) { e.printStackTrace(); } finally { HttpToolKit.closeQuiet(response); } System.out.println("*********" + i + "???*********"); } return Result.SUCCESS.json(null, null); }