List of usage examples for java.sql Timestamp valueOf
@SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime)
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.FirstJoinRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject request, ClientMonitor client) throws Exception { //System.out.println("Handler: starting..."); PreparedStatement stmt = conn.prepareStatement(stmts.get(SQLString.GET_NEW_PLAYER_LOGINS_HOURLY)); stmt.clearParameters();//from ww w .ja va 2 s . c om stmt.setTimestamp(1, Timestamp.valueOf(LocalDate.parse(request.getString("start")).atStartOfDay())); stmt.setTimestamp(2, Timestamp.valueOf(LocalDate.parse(request.getString("end")).plusDays(1).atStartOfDay())); ResultSet res = stmt.executeQuery(); Map<String, Integer> counts = new HashMap<>(); while (res.next()) { counts.put(res.getTimestamp("hour_joined").toLocalDateTime().toString(), res.getInt("login_count")); } JSONObject ret = new JSONObject(); ret.put("first_login_counts", counts); res.close(); stmt.close(); //System.out.println("Handler: done, returning."); return ret; }
From source file:org.apache.stratos.usage.summary.helper.DailySummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos usage daily summarization."); try {//from www. j a v a 2s . c o m String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageDailyTimestamp(); Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); String currentTsStr = formatter.format(new Date().getTime()); Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000; log.info("Running daily usage analytics from " + lastDailyTimestampStr + " to " + currentTsStr); setProperty("last_daily_ts", lastDailyTimestampSecs.toString()); setProperty("current_daily_ts", currentTsSecs.toString()); } catch (Exception e) { log.error("An error occurred while setting date range for daily usage analysis. ", e); } }
From source file:at.alladin.rmbt.db.fields.TimestampField.java
@Override public void setField(final JSONObject obj) { if (jsonKey != null && obj.has(jsonKey)) value = Timestamp.valueOf(obj.optString(jsonKey, null)); }
From source file:org.apache.stratos.usage.summary.helper.HourlyServiceStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos service stats hourly summarization."); try {// w ww .j av a2 s . com String lastHourlyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastServiceStatsHourlyTimestamp(); Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime(); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00"); String currentTsStr = formatter.format(new Date().getTime()); log.info("Running hourly service stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr); setProperty("last_hourly_ts", lastHourlyTimestamp.toString()); } catch (Exception e) { log.error("An error occurred while setting hour range for hourly service stats analysis. ", e); } }
From source file:org.apache.stratos.usage.summary.helper.HourlyCartridgeStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos cartridge stats hourly summarization."); try {/*from w ww .j a va2 s .c o m*/ String lastHourlyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastCartridgeStatsHourlyTimestamp(); Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime(); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00"); String currentTsStr = formatter.format(new Date().getTime()); log.info("Running hourly cartridge stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr); setProperty("last_hourly_ts", lastHourlyTimestamp.toString()); } catch (Exception e) { log.error("An error occurred while setting hour range for hourly cartridge stats analysis. ", e); } }
From source file:org.apache.stratos.usage.summary.helper.MonthlyServiceStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos service stats monthly summarization."); try {/* w w w . j av a2 s .c o m*/ String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageMonthlyTimestamp(); Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); String currentTsStr = formatter.format(new Date().getTime()); Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000; log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr); setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString()); setProperty("current_monthly_ts", currentTsSecs.toString()); } catch (Exception e) { log.error("An error occurred while setting month range for monthly service stats analytics. ", e); } }
From source file:org.apache.stratos.usage.summary.helper.MonthlySummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos usage monthly summarization."); try {//from ww w . j a v a 2s.c o m String lastMonthlyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastServiceStatsMonthlyTimestamp(); Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); String currentTsStr = formatter.format(new Date().getTime()); Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000; log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr); setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString()); setProperty("current_monthly_ts", currentTsSecs.toString()); } catch (Exception e) { log.error("An error occurred while setting month range for monthly service stats analysis. ", e); } }
From source file:org.apache.stratos.usage.summary.helper.DailyServiceStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos service stats daily summarization."); try {/*from w w w . j av a 2 s. com*/ String lastDailyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastServiceStatsDailyTimestamp(); Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); String currentTsStr = formatter.format(new Date().getTime()); Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000; log.info("Running daily service stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr); setProperty("last_daily_ts", lastDailyTimestampSecs.toString()); setProperty("current_daily_ts", currentTsSecs.toString()); } catch (Exception e) { log.error("An error occurred while setting date range for daily service stats analysis. ", e); } }
From source file:org.apache.stratos.usage.summary.helper.DailyCartridgeStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos cartridge stats daily summarization."); try {/*from ww w . j a v a 2s .c o m*/ String lastDailyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastCartridgeStatsDailyTimestamp(); Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); String currentTsStr = formatter.format(new Date().getTime()); Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000; log.info("Running daily cartridge stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr); setProperty("last_daily_ts", lastDailyTimestampSecs.toString()); setProperty("current_daily_ts", currentTsSecs.toString()); } catch (Exception e) { log.error("An error occurred while setting date range for daily cartridge stats analysis. ", e); } }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.PastOnlinePlayerCountRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject req, ClientMonitor c) throws SQLException { //System.out.println("Handler: starting..."); PreparedStatement stmt = conn.prepareStatement(stmts.get(SQLString.GET_HOURLY_PLAYER_COUNTS)); stmt.clearParameters();/* ww w . jav a 2s .c o m*/ stmt.setTimestamp(1, Timestamp.valueOf(LocalDateTime.parse(req.getString("start")))); stmt.setTimestamp(2, Timestamp.valueOf(LocalDateTime.parse(req.getString("end")))); ResultSet res = stmt.executeQuery(); Map<String, Integer> counts = new HashMap<>(); while (res.next()) { counts.put(res.getTimestamp("instant").toLocalDateTime().toString(), res.getInt("count")); } JSONObject ret = new JSONObject(); ret.put("counts", counts); res.close(); stmt.close(); conn.close(); //System.out.println("Handler: done, returning."); return ret; }