List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:com.hangum.tadpole.engine.query.sql.TadpoleSystem_SchemaHistory.java
/** * save schema_history //from www.j a v a 2 s . c om * * @param user_seq * @param userDB * @param strSQL */ public static SchemaHistoryDAO save(int user_seq, UserDBDAO userDB, String strSQL) { SchemaHistoryDAO schemaDao = new SchemaHistoryDAO(); try { // // // String strWorkSQL = strSQL.replaceAll("(\r\n|\n|\r)", ""); // ? . strWorkSQL = strWorkSQL.replaceAll("\\p{Space}", " "); // ? . if (logger.isDebugEnabled()) logger.debug("[start sql]\t" + strWorkSQL); String[] arrSQL = StringUtils.split(strWorkSQL); if (arrSQL.length != 5) return null; String strWorkType = arrSQL[0]; // object type String strObjecType = arrSQL[1]; // objectId String strObjectId = StringUtils.remove(arrSQL[2], "("); if (StringUtils.equalsIgnoreCase("or", strObjecType)) { strObjecType = arrSQL[3]; strObjectId = StringUtils.remove(arrSQL[4], "("); } schemaDao = new SchemaHistoryDAO(); schemaDao.setDb_seq(userDB.getSeq()); schemaDao.setUser_seq(user_seq); schemaDao.setWork_type(strWorkType); schemaDao.setObject_type(strObjecType); schemaDao.setObject_id(strObjectId); schemaDao.setCreate_date(new Timestamp(System.currentTimeMillis())); schemaDao.setIpaddress(RWT.getRequest().getRemoteAddr()); SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); SchemaHistoryDAO schemaHistoryDao = (SchemaHistoryDAO) sqlClient.insert("sqlHistoryInsert", schemaDao); //$NON-NLS-1$ insertResourceData(schemaHistoryDao, strSQL); } catch (Exception e) { logger.error("Schema histor save error", e); } return schemaDao; }
From source file:com.concursive.connect.web.modules.profile.utils.ProjectUtils.java
public static int queryWhatsNewCount(Connection db, int userId) throws SQLException { int count = 0; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, -2); Timestamp alertRangeStart = new Timestamp(cal.getTimeInMillis()); // Latest News BlogPostList newsList = new BlogPostList(); newsList.setForUser(userId);//from w w w . j a v a 2s. c om newsList.setAlertRangeStart(alertRangeStart); newsList.setCurrentNews(Constants.TRUE); count += newsList.queryCount(db); // Latest Issues TopicList topicList = new TopicList(); topicList.setForUser(userId); topicList.setAlertRangeStart(alertRangeStart); count += topicList.queryCount(db); // Latest Files FileItemList fileItemList = new FileItemList(); fileItemList.setLinkModuleId(Constants.PROJECTS_FILES); fileItemList.setForProjectUser(userId); fileItemList.setAlertRangeStart(alertRangeStart); count += fileItemList.queryCount(db); // Latest Wikis WikiList wikiList = new WikiList(); wikiList.setForUser(userId); wikiList.setAlertRangeStart(alertRangeStart); count += wikiList.queryCount(db); return count; }
From source file:outfox.dict.contest.service.ContestService.java
/** * ??//from www.jav a 2 s .c o m * @param singerEntity * @param callback * @return */ public String signup(HttpServletRequest req, SingerEntity singerEntity, RequestParams params) { String callback = params.getCallback(); // jsonp? String userId = ContestUtil.getUserId(req); // ? boolean limitLogin = params.isLimitLogin(); // ?? int state = params.getState(); // state0state1? if (state == 0) { // if (StringUtils.isBlank(userId) && limitLogin) { return Result.NOT_LOGIN.json(null, callback); } } else { // 1: ??? if (!verifyAuthority(userId)) { return Result.PERMISSION_DENIED.json(null, callback); } } HttpResponse response = null; try { // ???? singerEntity.setUserId(userId); 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() + "\", \"musicName\": \"" + singerEntity.getMusicName() + "\", \"state\": " + singerEntity.getState() + "}"; 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); JSONObject resObj = null; if (response != null) { HttpEntity resEntity = response.getEntity(); if (resEntity != null) { resObj = JSON.parseObject(EntityUtils.toString(resEntity)); } } int optionId = 0; if (resObj != null) { optionId = resObj.getJSONObject("data").getIntValue("optionId"); } // 3: redis String optionVoteKey = ContestConsts.VOTE_OPTION_PREFIX_KEY + ContestConsts.VOTE_ID; Map<String, String> optionNumMap = new HashMap<String, String>(); optionNumMap.put(String.valueOf(optionId), "0"); if (redisClient.notExists(optionVoteKey)) { // miss cache redisClient.hmset(optionVoteKey, optionNumMap, ContestConsts.EXPIRE_SECONDS); } else { // hit cache redisClient.hmset(optionVoteKey, optionNumMap); } // 4: JSONObject dataObj = new JSONObject(); dataObj.put("id", optionId); return Result.SUCCESS.json(dataObj, callback); } catch (Exception e) { LOG.error("ContestService.signup error...", e); } finally { HttpToolKit.closeQuiet(response); } return Result.SERVER_ERROR.json(null, callback); }
From source file:com.amazonaws.services.cognito.streams.connector.AmazonCognitoStreamsEventBeanTransformer.java
@Override public String toDelimitedString(AmazonCognitoStreamsEventBean dataObject) { StringBuilder builder = new StringBuilder(); StringBuilder dataBuilder = new StringBuilder(); dataBuilder.append(dataObject.getIdentityPoolId()).append(delim).append(dataObject.getIdentityId()) .append(delim).append(truncate(sanitize(dataObject.getDatasetName()), 128)).append(delim) .append(dataObject.getOperation()); String repeatingPart = dataBuilder.toString(); // If the data object has a URL, parse the records from the S3 file if (dataObject.getKinesisSyncRecordsURL() != null) { LOG.info("fetching records from " + dataObject.getKinesisSyncRecordsURL()); try {//from w w w. j a v a 2s . com URL url = new URL(dataObject.getKinesisSyncRecordsURL()); List<AmazonCognitoStreamsRecordBean> parsed = om.readValue(url.openStream(), om.getTypeFactory() .constructCollectionType(List.class, AmazonCognitoStreamsRecordBean.class)); dataObject.setKinesisSyncRecords(parsed); } catch (Exception e) { LOG.error("Unable to parse S3 payload", e); throw new RuntimeException("Unable to parse S3 payload", e); } LOG.info("fetched " + dataObject.getKinesisSyncRecords().size() + " records from S3"); } // For some operations, neither records nor URL will be populated if (dataObject.getKinesisSyncRecords() == null) { AmazonCognitoStreamsRecordBean tempBean = new AmazonCognitoStreamsRecordBean(); tempBean.setDeviceLastModifiedDate(new Date()); tempBean.setLastModifiedDate(new Date()); dataObject.setKinesisSyncRecords(ImmutableList.of(tempBean)); } for (AmazonCognitoStreamsRecordBean recordObject : dataObject.getKinesisSyncRecords()) { builder.append(repeatingPart).append(delim).append(truncate(sanitize(recordObject.getKey()), 1024)) .append(delim).append(truncate(sanitize(recordObject.getValue()), 4096)).append(delim) .append(recordObject.getOp()).append(delim).append(recordObject.getSyncCount()).append(delim) .append(new Timestamp(recordObject.getDeviceLastModifiedDate().getTime())).append(delim) .append(new Timestamp(recordObject.getLastModifiedDate().getTime())).append("\n"); } LOG.info("processed " + dataObject.getKinesisSyncRecords().size() + " records from Kinesis"); return builder.toString(); }
From source file:org.uaa.admin.resource.Profiles.java
@Path("/add") @POST/* w ww . j a va 2s. c o m*/ @Produces(MediaType.APPLICATION_JSON) public String addProfile(@FormParam("real_name") String realname, @FormParam("age") Integer age, @FormParam("nationality") String nationality, @FormParam("language") String language, @FormParam("gender") String gender, @FormParam("birthday") String birthday, @FormParam("idtype") String idtype, @FormParam("idnum") String idnum, @FormParam("department") String department, @FormParam("position") String position, @FormParam("address") String address, @FormParam("description") String description) { request = uriInfo.getRequestUri().toString(); Integer uid = SecurityContextHolder.getContext().getAuthenticationToken().getUid(); Profile profile = new Profile(); profile.setUser_id(uid); if (realname != null && !realname.equals("")) profile.setRealname(realname); if (age != null && age != 0) profile.setAge(age); if (nationality != null && !nationality.equals("")) profile.setNationality(nationality); if (language != null && !language.equals("")) profile.setLanguage(language); if (gender != null && !gender.equals("")) profile.setGender(gender); if (birthday != null && !birthday.equals("")) { try { java.sql.Date birth = new java.sql.Date(birthDayformat.parse(birthday).getTime()); profile.setBirthday(birth); } catch (ParseException e) { e.printStackTrace(); } } if (idtype != null && !idtype.equals("")) profile.setIdtype(idtype); if (idnum != null && !idnum.equals("")) profile.setIdnum(idnum); if (department != null && !department.equals("")) profile.setDepartment(department); if (position != null && !position.equals("")) profile.setPosition(position); if (address != null && !address.equals("")) profile.setAddress(address); if (description != null && !description.equals("")) profile.setDescription(description); profile.setLast_modify_person(uid); profile.setLast_modify_time(new Timestamp(System.currentTimeMillis())); profileService.insertProfile(profile); request = uriInfo.getPath(); ResponseWithStatus response = new ResponseWithStatus(request, "10000", "Add Profile Successfully"); return response.toJson(); }
From source file:hoot.services.models.osm.Changeset.java
/** * Closes a changeset//from ww w.j ava2s . c om * * @param changesetId ID of the changeset to close * @param conn JDBC Connection * @throws Exception */ public static void closeChangeset(final long mapId, final long changesetId, Connection dbConn) throws Exception { Changeset changeset = new Changeset(mapId, changesetId, dbConn); changeset.verifyAvailability(); final Timestamp now = new Timestamp(Calendar.getInstance().getTimeInMillis()); new SQLUpdateClause(dbConn, DbUtils.getConfiguration(mapId), changesets) .where(changesets.id.eq(changesetId)).set(changesets.closedAt, now).execute(); }
From source file:com.impetus.kundera.property.accessor.SQLTimestampAccessor.java
@Override public Timestamp getCopy(Object object) { Timestamp ts = (Timestamp) object; return ts != null ? new Timestamp(ts.getTime()) : null; }
From source file:fr.mby.opa.picsimpl.dao.DbPictureDao.java
@Override public List<Picture> findPicturesByAlbumId(final Long albumId, final Long since) { Assert.notNull(albumId, "Album Id should be supplied !"); final Timestamp sinceTimstamp = new Timestamp((since != null) ? since : 0L); final EmCallback<List<Picture>> emCallback = new EmCallback<List<Picture>>(this.getEmf()) { @Override//from w ww.ja v a 2 s . c om @SuppressWarnings("unchecked") protected List<Picture> executeWithEntityManager(final EntityManager em) throws PersistenceException { final Query findByAlbumQuery = em.createNamedQuery(Picture.FIND_PICTURE_BY_ALBUM_ORDER_BY_DATE); findByAlbumQuery.setParameter("albumId", albumId); findByAlbumQuery.setParameter("since", sinceTimstamp); findByAlbumQuery.setMaxResults(DbPictureDao.PAGINATION_SIZE); final List<Picture> pictureId = findByAlbumQuery.getResultList(); return pictureId; } }; List<Picture> pictures = emCallback.getReturnedValue(); if (pictures == null) { pictures = Collections.emptyList(); } return pictures; }
From source file:com.ginkgocap.tongren.organization.certified.web.CertifiedController.java
/*** * ?//from w w w. jav a 2 s . c om * @param request * @param response */ @RequestMapping(value = "/apply.json", method = RequestMethod.POST) public void apply(HttpServletRequest request, HttpServletResponse response) { Map<String, Object> notification = new HashMap<String, Object>(); Map<String, Object> responseData = new HashMap<String, Object>(); String paramsKey[] = { "verifyCode|R", "organizationId|R", "fullName|R", "introduction|R", "organizationType|R", "legalPerson|R", "legalPersonMobile|R", "logo|R", "businessLicense|R", "identityCard|R" }; ParamInfo params = null; try { RequestInfo ri = validate(request, response, paramsKey); if (ri == null) { return; } User user = ri.getUser(); params = ri.getParams(); String requestVerifyCode = params.getParam("verifyCode"); if (containsCode(user.getId(), requestVerifyCode) == false) { warpMsg(SysCode.PARAM_IS_ERROR, "???", params, response); return; } Certified certified = new Certified(); certified.setBusinessLicense(params.getParam("businessLicense")); certified.setFullName(params.getParam("fullName")); certified.setIdentityCard(params.getParam("identityCard")); certified.setIntroduction(params.getParam("introduction")); certified.setLegalPerson(params.getParam("legalPerson")); certified.setLegalPersonMobile(params.getParam("legalPersonMobile")); certified.setLogo(params.getParam("logo")); certified.setOperUserId(user.getUid()); certified.setOrganizationId(Long.parseLong(params.getParam("organizationId"))); certified.setOrganizationType(Integer.parseInt(params.getParam("organizationType"))); certified.setCreateTime(new Timestamp(System.currentTimeMillis())); certified.setUpdateTime(certified.getCreateTime()); certified.setStatus("1"); String status = certifiedService.add(certified); if (status.charAt(0) == '1') { certified.setId(Long.parseLong(status.substring(2))); responseData.put("certified", warpToView(certified)); renderResponseJson(response, params.getResponse(SysCode.SUCCESS, genResponseData(responseData, notification))); } else if (status.equals("2")) { warpMsg(SysCode.PARAM_IS_ERROR, "????", params, response); return; } else if (status.equals("3")) { warpMsg(SysCode.ERROR_CODE, "??", params, response); return; } } catch (Exception e) { warpMsg(SysCode.SYS_ERR, SysCode.SYS_ERR.getMessage(), params, response); e.printStackTrace(); return; } }
From source file:fr.paris.lutece.plugins.crm.service.demand.DemandService.java
/** * Create a new demand/*from w ww . j a v a 2s.c o m*/ * @param demand the demand * @return the newly created demand id */ public int create(Demand demand) { int nIdDemand = -1; if (demand != null) { demand.setDateModification(new Timestamp(new Date().getTime())); nIdDemand = DemandHome.create(demand); } return nIdDemand; }