List of usage examples for java.sql Timestamp valueOf
@SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime)
From source file:org.apache.stratos.usage.summary.helper.MonthlyCartridgeStatsSummarizerHelper.java
public void execute() { log.info("Running custom analyzer for Stratos cartridge stats monthly summarization."); try {// w ww. j a va 2 s . c o m String lastMonthlyTimestampStr = DataAccessObject.getInstance() .getAndUpdateLastCartridgeStatsMonthlyTimestamp(); 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 cartridge 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 cartridge stats analytics. ", e); } }
From source file:vn.edu.vttu.ui.PanelStatiticsRevenue.java
private void statiticsMonth() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String datetimeStart = formatter.format(dtFormDate.getDate()); Timestamp tsStart = Timestamp.valueOf(datetimeStart); String datetimeEnd = formatter.format(dtToDate.getDate()); Timestamp tsToDate = Timestamp.valueOf(datetimeEnd); tbResult.setModel(Invoice.getStatiticsByMonth(tsStart, tsToDate, ConnectDB.conn())); }
From source file:at.alladin.rmbt.db.fields.TimestampField.java
@Override public void setString(final String string) { value = Timestamp.valueOf(string); }
From source file:com.khartec.waltz.data.access_log.AccessLogDao.java
public int write(AccessLog logEntry) { return dsl.insertInto(ACCESS_LOG).set(ACCESS_LOG.PARAMS, logEntry.params()) .set(ACCESS_LOG.STATE, logEntry.state()).set(ACCESS_LOG.USER_ID, logEntry.userId()) .set(ACCESS_LOG.CREATED_AT, Timestamp.valueOf(logEntry.createdAt())).execute(); }
From source file:org.totschnig.myexpenses.Utils.java
/** * utility method that calls formatters for date * @param text// www . ja v a 2 s . c o m * @return formated string */ static String convDate(String text) { SimpleDateFormat formatter = new SimpleDateFormat("dd.MM HH:mm"); return formatter.format(Timestamp.valueOf(text)); }
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static Timestamp getTimestamp(final LocalDateTime datetime) { return datetime != null ? Timestamp.valueOf(datetime) : null; }
From source file:com.zotoh.core.util.DataUte.java
/** * @param obj//from w w w . j av a2 s . c o m * @return */ public static Timestamp toTimestamp(Object obj) { if (isNull(obj)) throw new RuntimeException("Null object conversion not allowed"); if (obj instanceof Timestamp) { return (Timestamp) obj; } else { return Timestamp.valueOf(obj.toString()); } }
From source file:com.zhengxuetao.gupiao.service.impl.DayServiceImpl.java
@Override public boolean saveDayDataFromFile(File file) { if (file != null && file.exists() && file.isFile()) { DayData dayData = new DayData(); String fileName = file.getName(); //SH#600004.txt dayData.setFinanceId(Long.parseLong(fileName.substring(3, 9))); String encoding = "GBK"; InputStreamReader reader = null; DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); DateFormat parseFormat = new SimpleDateFormat("yyyy-mm-dd"); try {//from w w w .j a v a 2 s . c o m reader = new InputStreamReader(new FileInputStream(file), encoding); BufferedReader bufferedReader = new BufferedReader(reader); String readLine; while ((readLine = bufferedReader.readLine()) != null) { //?????????? String[] arr = readLine.split(","); dayData.setTime(Timestamp.valueOf(format.format(parseFormat.parse(arr[0])))); dayData.setStartPrice(Float.valueOf(arr[1])); dayData.setHighPrice(Float.valueOf(arr[2])); dayData.setLowPrice(Float.valueOf(arr[3])); dayData.setEndPrice(Float.valueOf(arr[4])); dayData.setVolume(Long.valueOf(arr[5])); dayData.setAmount(Double.valueOf(arr[6])); userDAO.saveDayData(dayData); } } catch (IOException | ParseException ex) { logger.error(ex.getMessage()); } finally { try { reader.close(); } catch (IOException ex) { logger.error(ex.getMessage()); } } } else { logger.error("?!"); } return true; }
From source file:vn.edu.vttu.ui.PanelStatiticsRevenue.java
private void statiticsYear() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String datetimeStart = formatter.format(dtFormDate.getDate()); Timestamp tsStart = Timestamp.valueOf(datetimeStart); String datetimeEnd = formatter.format(dtToDate.getDate()); Timestamp tsToDate = Timestamp.valueOf(datetimeEnd); tbResult.setModel(Invoice.getStatiticsByYear(tsStart, tsToDate, ConnectDB.conn())); }
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static Timestamp getTimestamp(final LocalDate date) { return date != null ? Timestamp.valueOf(date.atStartOfDay()) : null; }