List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:fr.mby.opa.picsimpl.service.BasicProposalService.java
@Override public ProposalBranch createBranch(final String name, final String description, final Album album, final Long branchToForkId) { Assert.hasText(name, "No name supplied !"); Assert.notNull(album, "No Album supplied !"); final ProposalBranch branch = new ProposalBranch(); branch.setCreationTime(new Timestamp(System.currentTimeMillis())); branch.setName(name);/*from w w w . j a va 2 s . c o m*/ branch.setDescription(description); final ProposalBranch createdBranch; if (branchToForkId != null) { // We fork the branch => we duplicate it createdBranch = this.proposalDao.forkBranch(branch, branchToForkId); } else { createdBranch = this.proposalDao.createBranch(branch); } return createdBranch; }
From source file:org.dcache.chimera.PgSQLFsSqlDriver.java
@Override protected FsInode createInodeInParent(FsInode parent, String name, String id, int owner, int group, int mode, int type, int nlink, long size) { Timestamp now = new Timestamp(System.currentTimeMillis()); Long inumber = _jdbc.query("SELECT f_create_inode(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", cs -> { cs.setLong(1, parent.ino());/* w ww. j a v a 2 s . c o m*/ cs.setString(2, name); cs.setString(3, id); cs.setInt(4, type); cs.setInt(5, mode & UnixPermission.S_PERMS); cs.setInt(6, nlink); cs.setInt(7, owner); cs.setInt(8, group); cs.setLong(9, size); cs.setInt(10, _ioMode); cs.setTimestamp(11, now); }, rs -> rs.next() ? rs.getLong(1) : null); if (inumber == null) { throw new IncorrectUpdateSemanticsDataAccessException("f_create_inode failed to return an inumber."); } Stat stat = new Stat(); stat.setIno(inumber); stat.setId(id); stat.setCrTime(now.getTime()); stat.setGeneration(0); stat.setSize(size); stat.setATime(now.getTime()); stat.setCTime(now.getTime()); stat.setMTime(now.getTime()); stat.setUid(owner); stat.setGid(group); stat.setMode(mode & UnixPermission.S_PERMS | type); stat.setNlink(nlink); stat.setDev(17); stat.setRdev(13); return new FsInode(parent.getFs(), inumber, FsInodeType.INODE, 0, stat); }
From source file:com.qagen.osfe.core.utils.BeanPopulator.java
private static Timestamp getTimestamp(String name, String value, String format) { try {//from w w w . j a v a 2 s .c om if ((format == null) || (format.trim().length() == 0)) { final String message = "Column, " + name + " is define as a Timestamp and must the attribute, format, defined."; throw new FeedErrorException(message); } final SimpleDateFormat formatter = new SimpleDateFormat(format); return new Timestamp(formatter.parse(value).getTime()); } catch (ParseException e) { throw new FeedErrorException(e); } }
From source file:com.chevres.rss.restapi.dao.impl.UserAuthDAOImplTest.java
@Test public void testCreate() { String token = "fezfezgezgezg"; Timestamp createDate = new Timestamp(1132); UserAuth userAuth = new UserAuth(); userAuth.setIdUser(1);/*from ww w . j av a 2 s. c om*/ userAuth.setToken(token); userAuth.setCreateDate(createDate); userAuthDAO.create(userAuth); UserAuth createdUserAuth = userAuthDAO.findByToken(token); assertNotNull(createdUserAuth); assertEquals(createdUserAuth.getId(), 5); assertEquals(createdUserAuth.getCreateDate(), createDate); assertEquals(createdUserAuth.getIdUser(), 1); assertEquals(createdUserAuth.getToken(), token); }
From source file:cyrille.hibernate.temporal.Contrat.java
/** * @param atemporalId//from www .j ava 2s . c o m * @param description */ public Contrat(long atemporalId, String description) { super(); this.atemporalId = atemporalId; this.dateModificationContrat = new Timestamp(System.currentTimeMillis()); this.description = description; }
From source file:fitmon.DietAPI.java
public ArrayList<Food> getFood(String foodID) throws ClientProtocolException, IOException, NoSuchAlgorithmException, InvalidKeyException, SAXException, ParserConfigurationException { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://platform.fatsecret.com/rest/server.api&" + "oauth_consumer_key=5f2d9f7c250c4d75b9807a4f969363a7&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1408230438&" + "oauth_nonce=abc&oauth_version=1.0&method=food.get&food_id=33691"); HttpResponse response = client.execute(request); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String base = URLEncoder.encode("GET") + "&"; base += "http%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&"; String params;/* w ww .j av a2 s.c o m*/ params = "food_id=" + foodID + "&"; params += "method=food.get&"; params += "oauth_consumer_key=5f2d9f7c250c4d75b9807a4f969363a7&"; // ur consumer key params += "oauth_nonce=123&"; params += "oauth_signature_method=HMAC-SHA1&"; Date date = new java.util.Date(); Timestamp ts = new Timestamp(date.getTime()); params += "oauth_timestamp=" + ts.getTime() + "&"; params += "oauth_version=1.0"; //params += "search_expression=apple"; String params2 = URLEncoder.encode(params); base += params2; System.out.println(base); String line = ""; String secret = "76172de2330a4e55b90cbd2eb44f8c63&"; Mac sha256_HMAC = Mac.getInstance("HMACSHA1"); SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HMACSHA1"); sha256_HMAC.init(secret_key); String hash = Base64.encodeBase64String(sha256_HMAC.doFinal(base.getBytes())); //$url = "http://platform.fatsecret.com/rest/server.api?".$params."&oauth_signature=".rawurlencode($sig); String url = "http://platform.fatsecret.com/rest/server.api?" + params + "&oauth_signature=" + URLEncoder.encode(hash); System.out.println(url); xmlParser xParser = new xmlParser(); ArrayList<Food> foodList = xParser.Parser(url); return foodList; //while ((line = rd.readLine()) != null) { // System.out.println(line); //} }
From source file:core.commonapp.server.service.security.UserServiceImpl.java
@Override @Transactional/*w w w .j ava 2s. co m*/ public ServiceResult<UserLogin> createUserLogin(Person person, String username, String password) { /// ????: should use spring directory UserLogin userLogin = (UserLogin) context.getBean(UserLogin.class); userLogin.setParty(person); userLogin.setUsername(username); userLogin.setPassword(password); userLogin.setEnabled(true); userLogin.setCreatedDate(new Timestamp(System.currentTimeMillis())); return createUserLogin(userLogin); }
From source file:fr.mby.opa.picsimpl.dao.DbAlbumDao.java
@Override public Album createAlbum(final Album album) { Assert.notNull(album, "No Album supplied !"); Assert.isNull(album.getId(), "Id should not be set for creation !"); Assert.hasText(album.getName(), "No Album name supplied !"); new TxCallback(this.getEmf()) { @Override//w ww . ja va 2 s. c o m protected void executeInTransaction(final EntityManager em) { final Timestamp creationTime = new Timestamp(System.currentTimeMillis()); // Persist album album.setCreationTime(creationTime); album.setLocked(false); em.persist(album); // Create initial bag final ProposalBag initialBag = new ProposalBag(); initialBag.setCommited(false); initialBag.setCreationTime(creationTime); initialBag.setName(IProposalDao.INITIAL_PROPOSAL_NAME); initialBag.setRevision("0"); em.persist(initialBag); // Create master branch final ProposalBranch masterBranch = new ProposalBranch(); masterBranch.setAlbum(album); masterBranch.setCreationTime(creationTime); masterBranch.setName(IProposalDao.MASTER_BRANCH_NAME); masterBranch.setHead(initialBag); final List<ProposalBag> bagList = new ArrayList<>(); bagList.add(initialBag); masterBranch.setBags(bagList); em.persist(masterBranch); } }; return album; }
From source file:com.tesora.dve.db.mysql.MysqlNativeResultHandler.java
@Override protected byte[] getDateAsBytes(ColumnMetadata uc, Object obj) { if (uc.getDataType() == Types.TIME) return getTimeAsBytes(uc, new Time(((Date) obj).getTime())); if (uc.getDataType() == Types.TIMESTAMP) return getTimestampAsBytes(uc, new Timestamp(((Date) obj).getTime())); if (((Date) obj).equals(ZERO_DATE_INDICATOR)) return ZERO_DATE.getBytes(); return dateFormatter.format((Date) obj).getBytes(); }
From source file:ma.glasnost.orika.test.converter.CloneableConverterTestCase.java
@Test public void cloneableConverter() throws DatatypeConfigurationException { CloneableConverter cc = new CloneableConverter(SampleCloneable.class); MapperFactory factory = MappingUtil.getMapperFactory(); factory.getConverterFactory().registerConverter(cc); GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.YEAR, 10);/* w w w . jav a 2s . c o m*/ XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance() .newXMLGregorianCalendar((GregorianCalendar) cal); cal.add(Calendar.MONTH, 3); ClonableHolder source = new ClonableHolder(); source.value = new SampleCloneable(); source.value.id = 5L; source.date = new Date(System.currentTimeMillis() + 100000); source.timestamp = new Timestamp(System.currentTimeMillis() + 50000); source.calendar = cal; source.xmlCalendar = xmlCal; ClonableHolder dest = factory.getMapperFacade().map(source, ClonableHolder.class); Assert.assertEquals(source.value, dest.value); Assert.assertNotSame(source.value, dest.value); Assert.assertEquals(source.date, dest.date); Assert.assertNotSame(source.date, dest.date); Assert.assertEquals(source.timestamp, dest.timestamp); Assert.assertNotSame(source.timestamp, dest.timestamp); Assert.assertEquals(source.calendar, dest.calendar); Assert.assertNotSame(source.calendar, dest.calendar); Assert.assertEquals(source.xmlCalendar, dest.xmlCalendar); Assert.assertNotSame(source.xmlCalendar, dest.xmlCalendar); }