List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:de.interseroh.report.formatters.TimestampFormatter.java
@Override public String print(Timestamp date, Locale locale) { return getDateFormat(locale).format(new java.util.Date(date.getTime())); }
From source file:org.apache.hadoop.hive.ql.udf.generic.GenericUDFFromUtcTimestamp.java
protected Timestamp applyOffset(long offset, Timestamp t) { long newTime = t.getTime() + offset; Timestamp t2 = new Timestamp(newTime); t2.setNanos(t.getNanos());/*w ww .ja v a 2 s.c o m*/ return t2; }
From source file:net.sf.jasperreports.data.cache.TimestampStore.java
@Override public void addValue(Object object) { if (!(object instanceof Timestamp)) { throw new IllegalArgumentException(); }/*from ww w. j a v a 2 s. c om*/ Timestamp value = (Timestamp) object; long time = value.getTime(); int nanos = value.getNanos(); timeStore.add(time); nanoStore.add(nanos); }
From source file:dk.nsi.minlog.export.dao.ebean.StatusDaoEBean.java
@Override @Transactional// ww w. j a v a 2 s . co m public DateTime getLastUpdated() { SqlRow row = ebeanServer.createSqlQuery("SELECT * FROM status").findUnique(); //If there does not exist a from date, we just pick the earliest possible date if (row != null) { Timestamp date = row.getTimestamp("lastUpdated"); return new DateTime(date.getTime()); } else { return new DateTime(0); } }
From source file:org.zenoss.zep.dao.impl.compat.DatabaseCompatibilityPostgreSQL.java
@Override public TypeConverter<Long> getTimestampConverter() { return new TypeConverter<Long>() { @Override/*from ww w. j a va 2s. c om*/ public Long fromDatabaseType(ResultSet rs, String columnName) throws SQLException { Timestamp ts = rs.getTimestamp(columnName); return (ts != null) ? ts.getTime() : null; } @Override public Object toDatabaseType(Long timestampInMillis) { if (timestampInMillis == null) { return null; } return new Timestamp(timestampInMillis); } }; }
From source file:fitmon.WorkoutApi.java
public StringBuilder apiGetInfo() throws ClientProtocolException, IOException, NoSuchAlgorithmException, InvalidKeyException { 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=4384"); //HttpResponse response = client.execute(request); //BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent())); //StringBuilder sb = new StringBuilder(); String base = URLEncoder.encode("GET") + "&"; base += "http%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&"; String params;//from ww w .j a v a 2s .c o m params = "format=json&"; params += "method=exercises.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); HttpGet request = new HttpGet("http://platform.fatsecret.com/rest/server.api?" + params + "&oauth_signature=" + URLEncoder.encode(hash)); HttpResponse response = client.execute(request); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder sb = new StringBuilder(); //$url = "http://platform.fatsecret.com/rest/server.api?"+params+"&oauth_signature="+URLEncoder.encode(hash); //return url; while ((line = rd.readLine()) != null) { sb.append(line); //System.out.println(line); } //System.out.println(sb.toString()); return sb; }
From source file:egovframework.oe1.utl.fcc.service.EgovStringUtil.java
License:asdf
/** * ??? ? ?17??TIMESTAMP?//from w w w . j a v a 2 s. com * * @param * @return Timestamp * @exception MyException * @see */ public static String getTimeStamp() { String rtnStr = null; // ? (?--? :::(?? )) String pattern = "yyyyMMddhhmmssSSS"; try { SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA); Timestamp ts = new Timestamp(System.currentTimeMillis()); rtnStr = sdfCurrent.format(ts.getTime()); } catch (Exception e) { log.debug(e.getMessage()); } return rtnStr; }
From source file:org.emergent.plumber.InfoServlet.java
protected String getMsg(HttpServletRequest req) throws SQLException { String username = (String) req.getAttribute(ATTRIB_USERNAME_KEY); Connection conn = null;/*from w w w . j a v a2s . co m*/ PreparedStatement st = null; ResultSet rs = null; try { conn = getDatabaseConnection(req); st = conn.prepareStatement("SELECT E.engine, MAX(E.modified)" + " FROM WeaveUser U, EngineWbo E" + " WHERE U.userid = E.userid" + " AND U.username = ?" + " GROUP BY E.engine"); st.setString(1, username); rs = st.executeQuery(); JSONObject retvalObj = new JSONObject(); while (rs.next()) { String id = rs.getString(1); Timestamp modified = rs.getTimestamp(2); long mod = modified.getTime(); double modDouble = MiscUtil.toWeaveTimestampDouble(mod); retvalObj.put(id, modDouble); } return retvalObj.toString(); } catch (JSONException e) { throw new SQLException(e); } finally { MiscUtil.close(rs); MiscUtil.close(st); MiscUtil.close(conn); } }
From source file:com.springmvc.dao.TimeLogDAO.java
public void updateLogout(TimeLog timeLog) { TimeLog timeLogToUpdate = getTimeLog(timeLog.getId()); Date date = new Date(); Timestamp time = new Timestamp(date.getTime()); timeLogToUpdate.setLogout(time);/*from w ww. j a va2s.c o m*/ Timestamp login = timeLogToUpdate.getLogin(); long diff = Math.abs(login.getTime() - time.getTime()); long second = (diff / 1000) % 60; long minute = (diff / (1000 * 60)) % 60; long hour = (diff / (1000 * 60 * 60)) % 24; long day = (diff / (1000 * 60 * 60 * 24)); String toString = String.format("%02dd:%02dh:%02dm:%02ds", day, hour, minute, second, diff); timeLogToUpdate.setDuration(toString); getCurrentSession().update(timeLogToUpdate); }
From source file:net.mindengine.oculus.frontend.db.jdbc.BeanMapper.java
@Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { // TODO Auto-generated method stub ResultSetMetaData metaData = rs.getMetaData(); int columns = metaData.getColumnCount(); try {//from w w w. j a v a2s. c o m Class<?> clazz = Class.forName(className); Object obj = clazz.newInstance(); for (int i = 1; i <= columns; i++) { String column = metaData.getColumnName(i); FieldMapper fm = fields.get(column); if (fm != null) { Method method = fm.getMethod(); String typeName = fm.getType().getSimpleName(); typeName = StringUtils.capitalize(typeName); if (typeName.endsWith("[]")) { typeName = typeName.substring(0, typeName.length() - 2) + "s"; } if (typeName.equals("Date")) { typeName = "Timestamp"; } if (typeName.equals("Integer")) { typeName = "Int"; } Method rsMethod = ResultSet.class.getMethod("get" + typeName, String.class); Object value = rsMethod.invoke(rs, column); if (value instanceof Timestamp) { Timestamp timestamp = (Timestamp) value; value = new Date(timestamp.getTime()); } method.invoke(obj, value); } } return obj; } catch (Exception e) { throw new SQLException(e); } }