List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:net.chrisrichardson.foodToGo.restaurantNotificationService.tsImpl.dao.OrderDAOIBatisImpl.java
Timestamp calculateCutOffTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.MINUTE, -timeWindowInMinutes); long cutOffTime = c.getTimeInMillis(); return new Timestamp(cutOffTime); }
From source file:com.ideabase.repository.test.TestCaseRepositoryHelper.java
public static List<Integer> fixCreateItems(final RepositoryService pRepositoryService, final int pNumberOfItems) { final List<Integer> itemIds = new ArrayList<Integer>(); final String dummyName = "the brown fox jump over the..."; final String dummyEmail = "hasan@somewherein.net"; for (int i = 0; i < pNumberOfItems; i++) { final GenericItem item = new GenericItem(); item.addField("name", dummyName); item.addField("email", dummyEmail); item.addField("currentTime", String.valueOf(System.currentTimeMillis())); item.setTitle(dummyName);//from www .j ava 2s . c om item.setCreatedOn(new Timestamp(System.currentTimeMillis())); item.setLastUpdatedOn(item.getCreatedOn()); itemIds.add(pRepositoryService.save(item)); } return itemIds; }
From source file:org.dcache.chimera.H2FsSqlDriver.java
@Override Stat createInode(String id, int type, int uid, int gid, int mode, int nlink, long size) { /* H2 uses weird names for the column with the auto-generated key, so we cannot use the code * in the base class./*ww w.j a v a2s . c o m*/ */ Timestamp now = new Timestamp(System.currentTimeMillis()); KeyHolder keyHolder = new GeneratedKeyHolder(); _jdbc.update(con -> { PreparedStatement ps = con.prepareStatement( "INSERT INTO t_inodes (ipnfsid,itype,imode,inlink,iuid,igid,isize,iio," + "ictime,iatime,imtime,icrtime,igeneration) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)", Statement.RETURN_GENERATED_KEYS); ps.setString(1, id); ps.setInt(2, type); ps.setInt(3, mode & UnixPermission.S_PERMS); ps.setInt(4, nlink); ps.setInt(5, uid); ps.setInt(6, gid); ps.setLong(7, size); ps.setInt(8, _ioMode); ps.setTimestamp(9, now); ps.setTimestamp(10, now); ps.setTimestamp(11, now); ps.setTimestamp(12, now); ps.setLong(13, 0); return ps; }, keyHolder); Stat stat = new Stat(); stat.setIno((Long) keyHolder.getKey()); 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(uid); stat.setGid(gid); stat.setMode(mode & UnixPermission.S_PERMS | type); stat.setNlink(nlink); stat.setDev(17); stat.setRdev(13); return stat; }
From source file:com.leixl.easyframework.system.service.impl.EUserServiceImpl.java
public EUser save(String username, String email, String password, String ip) { Date now = new Timestamp(System.currentTimeMillis()); EUser user = new EUser(); user.setUsername(username);//from w w w. ja v a2 s .c o m user.setEmail(email); user.setPassword(pwdEncoder.encodePassword(password)); user.setRegisterIp(ip); user.setRegisterTime(now); user.setLastLoginIp(ip); user.setLastLoginTime(now); //?? user.setActivation(true); user.init(); dao.save(user); return user; }
From source file:net.chrisrichardson.bankingExample.domain.jdbc.JdbcAccountDao.java
public void addAccount(Account account) { logger.debug("adding account"); int count = jdbcTemplate.update( "INSERT INTO BANK_ACCOUNT(accountId, BALANCE, overdraftPolicy, dateOpened, requiredYearsOpen, limit) values(?, ?, ?, ?, ?, ?)", new Object[] { account.getAccountId(), account.getBalance(), account.getOverdraftPolicy(), new Timestamp(account.getDateOpened().getTime()), account.getRequiredYearsOpen(), account.getLimit() }, new int[] { Types.VARCHAR, Types.DOUBLE, Types.INTEGER, Types.TIMESTAMP, Types.DOUBLE, Types.DOUBLE }); Assert.isTrue(count == 1);//from w w w . j a v a 2s . c o m }
From source file:gsi.pushlet.PushletCaronte.java
/** * Run.//from w w w.jav a 2 s .com */ public void run() { // Create and start a Pushlet client; we receive callbacks through onHeartbeat() and onData(). try { pushletClient = new PushletClient(host, port); pushletClient.setDebug(true); pushletClient.join(); pushletClient.listen(this, Protocol.MODE_STREAM); pushletClient.subscribe(SUBJECT); System.out.println("pushletClient started"); } catch (PushletException pe) { System.out.println("Error in setting up pushlet session pe=" + pe); return; } // Publish an event to the server every N seconds. HashMap<String, String> eventData = new HashMap<String, String>(2); String fecha = "1992-01-01 00:00:01.000"; while (true) { try { JSONArray array = getCatastrofes(fecha); fecha = new Timestamp(new Date().getTime()).toString(); if (array.length() > 0) { // Create event data eventData.put("fecha", fecha); eventData.put("datos", array.toString()); // POST event to pushlet server pushletClient.publish(SUBJECT, eventData); System.out.println("publicado con " + array.length() + " datos"); } Thread.sleep(PUBLISH_INTERVAL); } catch (PushletException ex) { System.out.println("PushletException: " + ex); } catch (InterruptedException ex) { System.out.println("InterruptedException: " + ex); } } }
From source file:edgeserver.Publicacao.java
public void publica(String urlLogin, String urlInsertDado) throws Exception { // make sure cookies is turn on CookieHandler.setDefault(new CookieManager()); Date datapublicacao = new Date(); HTTPClient http = new HTTPClient(); List<NameValuePair> postp = new ArrayList<>(); postp.add(new BasicNameValuePair("login", "huberto")); postp.add(new BasicNameValuePair("password", "99766330")); http.sendPost(urlLogin, postp);// w w w.j a v a 2 s .co m List<NameValuePair> GatewayParams = new ArrayList<>(); GatewayParams.add(new BasicNameValuePair("publicacao_servidorborda", Integer.toString(this.servidorborda))); GatewayParams.add(new BasicNameValuePair("publicacao_sensor", Integer.toString(this.sensor))); GatewayParams.add(new BasicNameValuePair("publicacao_datacoleta", this.datacoleta.toString())); GatewayParams.add(new BasicNameValuePair("publicacao_datapublicacao", new Timestamp(datapublicacao.getTime()).toString())); GatewayParams.add(new BasicNameValuePair("publicacao_valorcoletado", Float.toString(this.valorcoletado))); String result = http.GetPageContent(urlInsertDado, GatewayParams); }
From source file:ru.org.linux.group.TopicsListItem.java
public TopicsListItem(User author, SqlRowSet rs, int messagesInPage, ImmutableList<String> tags) { this.author = author; this.tags = tags; subj = StringUtil.makeTitle(rs.getString("subj")); Timestamp lastmod = rs.getTimestamp("lastmod"); if (lastmod == null) { this.lastmod = new Timestamp(0); } else {//from ww w. jav a 2s . c om this.lastmod = lastmod; } msgid = rs.getInt("msgid"); deleted = rs.getBoolean("deleted"); stat1 = rs.getInt("stat1"); stat3 = rs.getInt("stat3"); stat4 = rs.getInt("stat4"); sticky = rs.getBoolean("sticky"); resolved = rs.getBoolean("resolved"); pages = Topic.getPageCount(stat1, messagesInPage); }
From source file:com.nettyhttpserver.server.NettyChannelTrafficShapingHandler.java
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { connectionInfo.setIp(((InetSocketAddress) ctx.channel().remoteAddress()).getHostString()); connectionInfo.setTimestamp(new Timestamp(System.currentTimeMillis())); super.channelActive(ctx); }
From source file:edu.duke.cabig.c3pr.domain.User.java
public void resetToken() { this.tokenTime = new Timestamp(0); }