List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:Main.java
public static void main(String[] args) { java.util.Date today = new java.util.Date(); java.sql.Timestamp ts1 = new java.sql.Timestamp(today.getTime()); long tsTime1 = ts1.getTime(); System.out.println(tsTime1);// w ww .j a va2 s .co m }
From source file:Main.java
public static void main(String[] args) { java.sql.Timestamp ts2 = java.sql.Timestamp.valueOf("2005-04-06 09:01:10"); long tsTime2 = ts2.getTime(); System.out.println(tsTime2);// w ww .j a v a 2s . c o m }
From source file:Main.java
public static void main(String[] args) { java.sql.Timestamp ts2 = java.sql.Timestamp.valueOf("2013-04-06 09:01:10"); long tsTime2 = ts2.getTime(); System.out.println(tsTime2);//from w w w .java 2 s .c o m }
From source file:Main.java
public static void main(String[] args) { Timestamp timestamp = new Timestamp(System.currentTimeMillis()); Date date = new Date(timestamp.getTime()); // S is the millisecond SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy' 'HH:mm:ss:S"); System.out.println(simpleDateFormat.format(timestamp)); System.out.println(simpleDateFormat.format(date)); }
From source file:Main.java
public static void main(String[] args) { java.sql.Timestamp ts2 = java.sql.Timestamp.valueOf("2013-04-06 09:01:10"); long tsTime2 = ts2.getTime(); System.out.println(tsTime2);/*w w w . ja v a2 s .co m*/ ts2.setNanos(123); System.out.println(tsTime2); }
From source file:DateLabel.java
public static void main(String[] args) { java.util.Date today = new java.util.Date(); java.sql.Timestamp ts1 = new java.sql.Timestamp(today.getTime()); java.sql.Timestamp ts2 = java.sql.Timestamp.valueOf("2005-04-06 09:01:10"); long tsTime1 = ts1.getTime(); long tsTime2 = ts2.getTime(); System.out.println(tsTime1);//w ww . j av a2s.c o m System.out.println(tsTime2); }
From source file:Main.java
public static void main(String[] args) { long time = System.currentTimeMillis(); Date d = new Date(time); Timestamp t = new Timestamp(time); t.setNanos(123456789);/* w ww . ja v a 2s. co m*/ System.out.println(d); System.out.println(t); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'"); NumberFormat nf = new DecimalFormat("000000000"); System.out.println(df.format(t.getTime()) + nf.format(t.getNanos())); }
From source file:org.isatools.isatab.commandline.PersistenceShellCommand.java
public static void main(String[] args) { EntityTransaction transaction = null; try {/*from ww w . j av a2 s . c o m*/ Options clopts = createCommonOptions(); CommandLine cmdl = AbstractImportLayerShellCommand.parseCommandLine(clopts, args, PersistenceShellCommand.class); args = cmdl.getArgs(); if (args == null || args.length == 0) { printUsage(clopts); System.exit(1); } setup(args); setupLog4JPath(cmdl, null); // Need to initialize this here, otherwise above config will fail log = Logger.getLogger(PersistenceShellCommand.class); Properties hibProps = AbstractImportLayerShellCommand.getHibernateProperties(); hibProps.setProperty("hibernate.search.indexing_strategy", "manual"); hibProps.setProperty("hibernate.hbm2ddl.auto", "update"); hibProps.setProperty("hbm2ddl.drop", "false"); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("BIIEntityManager", hibProps); EntityManager entityManager = entityManagerFactory.createEntityManager(); BIIObjectStore store = loadIsaTab(); log.info(i18n.msg("mapping_done_now_persisting", store.size())); ISATABPersister persister = new ISATABPersister(store, DaoFactory.getInstance(entityManager)); transaction = entityManager.getTransaction(); transaction.begin(); Timestamp ts = persister.persist(sourceDirPath); transaction.commit(); entityManager.close(); reindexStudies(store, hibProps); log.info("\n\n" + i18n.msg("mapping_done_data_saved_in_db")); log.info("\n\n" + i18n.msg("submission_done_ts_reported", "" + ts.getTime(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(ts) + "." + ts.getNanos()) + "\n"); System.exit(0); } catch (Exception ex) { String msg = "ERROR: problem while running the ISATAB loader: " + ex.getMessage(); if (log == null) { out.println(msg + "\n"); ex.printStackTrace(); } else { log.fatal(msg, ex); } System.exit(1); } }
From source file:Main.java
public static java.util.Date sqlTimestampToDate(Timestamp t) { return t != null ? new java.util.Date(Math.round(t.getTime() + t.getNanos() / 1000000D)) : null; }
From source file:Main.java
public static String getDateTimeTextFromTimestamp(Long timestamp) { Timestamp stamp = new Timestamp(timestamp); Date date = new Date(stamp.getTime()); Calendar cal = Calendar.getInstance(); SimpleDateFormat s = new SimpleDateFormat("dd MMM yyyy HH:mm"); s.setTimeZone(cal.getTimeZone());/*from w ww . j a v a 2 s. c o m*/ return s.format(date); }