List of usage examples for java.sql Timestamp toString
@SuppressWarnings("deprecation") public String toString()
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"); System.out.println(ts2.toString()); }
From source file:MainClass.java
public static void main(String[] args) { try {/*from www . j a v a 2s .com*/ String FILE = "c:\\systemin.txt"; FileOutputStream outStr = new FileOutputStream(FILE, true); PrintStream printStream = new PrintStream(outStr); System.setErr(printStream); Timestamp now = new Timestamp(System.currentTimeMillis()); System.out.println(now.toString() + ": This is text that should go to the file"); outStr.close(); printStream.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); System.exit(-1); } catch (IOException ex) { ex.printStackTrace(); System.exit(-1); } }
From source file:Main.java
public static void main(String[] args) { java.util.Date javaDate = new java.util.Date(); long javaTime = javaDate.getTime(); System.out.println("The Java Date is: " + javaDate.toString()); java.sql.Date sqlDate = new java.sql.Date(javaTime); System.out.println("The SQL DATE is: " + sqlDate.toString()); java.sql.Time sqlTime = new java.sql.Time(javaTime); System.out.println("The SQL TIME is: " + sqlTime.toString()); java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime); System.out.println("The SQL TIMESTAMP is: " + sqlTimestamp.toString()); }
From source file:Main.java
public static void main(String[] args) { java.util.Date javaDate = new java.util.Date(); long javaTime = javaDate.getTime(); System.out.println("The Java Date is:" + javaDate.toString()); // SQL DATE//from w w w .ja v a 2 s .c o m java.sql.Date sqlDate = new java.sql.Date(javaTime); System.out.println("The SQL DATE is: " + sqlDate.toString()); // SQL TIME java.sql.Time sqlTime = new java.sql.Time(javaTime); System.out.println("The SQL TIME is: " + sqlTime.toString()); // SQL TIMESTAMP java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime); System.out.println("The SQL TIMESTAMP is: " + sqlTimestamp.toString()); }
From source file:Main.java
public static String getSeconds2() { java.util.Date date1 = new java.util.Date(); Timestamp stamp2 = new Timestamp(date1.getTime()); return stamp2.toString(); }
From source file:Main.java
public static String getSeconds1() { Timestamp stamp1 = new Timestamp(System.currentTimeMillis()); return stamp1.toString(); }
From source file:Main.java
public static String changeStringToDate3(String str) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date date6 = null;/*from w w w. j a va 2s . c o m*/ try { date6 = sdf.parse(str); java.sql.Date date7 = new java.sql.Date(date6.getTime()); Timestamp stamp9 = new Timestamp(date7.getTime()); return stamp9.toString(); } catch (ParseException e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static String getDateTime(long t) { Timestamp timestamp = new Timestamp(t / 1000000); //make it miliseconds from nanoseconds return timestamp.toString(); }
From source file:Util.java
public static Timestamp formatTimestamp(Timestamp datetime) { try {//w ww . j a v a2 s . c o m DateFormat formatter; String dateFormat = datetime.toString(); System.out.println("Truoc:" + datetime); formatter = new SimpleDateFormat("dd/MM/yyyy"); Date date = (Date) formatter.parse(dateFormat); java.sql.Timestamp timeStampDate = new Timestamp(date.getTime()); System.out.println("Sau:" + timeStampDate); return timeStampDate; } catch (ParseException e) { System.out.println("Exception :" + e); return null; } }
From source file:zz.pseas.ghost.utils.LoginUtils.java
public static String getCurrentTime() { Timestamp ts = new Timestamp(System.currentTimeMillis()); return ts.toString(); }