Example usage for java.sql Timestamp Timestamp

List of usage examples for java.sql Timestamp Timestamp

Introduction

In this page you can find the example usage for java.sql Timestamp Timestamp.

Prototype

public Timestamp(long time) 

Source Link

Document

Constructs a Timestamp object using a milliseconds time value.

Usage

From source file:Main.java

public static String getTempFileName() {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SS");
    return format.format(new Timestamp(System.currentTimeMillis()));
}

From source file:Main.java

public static String getTempFileName() {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SS");
    String fileName = format.format(new Timestamp(System.currentTimeMillis()));
    return fileName;
}

From source file:Main.java

private static String getCSTimeString(String timestamp) {
    return simpleDateFormat.format(new Timestamp(Long.parseLong(timestamp) * 1000));
}

From source file:Main.java

public static Timestamp toTimestamp(LocalDate localDate) {
    Date date = Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    Timestamp timeStamp = new Timestamp(date.getTime());
    return timeStamp;
}

From source file:Main.java

public static String getSysDateTime() {
    return new Timestamp(System.currentTimeMillis()).toString().substring(0, 19);
}

From source file:Util.java

public static Timestamp convertStringToTimestamp(String str_date) {
    try {//from  w  ww  .  j a v  a 2  s .c o m
        DateFormat formatter;
        formatter = new SimpleDateFormat("dd/MM/yyyy");
        Date date = (Date) formatter.parse(str_date);
        java.sql.Timestamp timeStampDate = new Timestamp(date.getTime());

        return timeStampDate;
    } catch (ParseException e) {
        System.out.println("Exception :" + e);
        return null;
    }
}

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;/* ww w.  j  a v a2 s. c  om*/
    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:Util.java

public static Timestamp formatTimestamp(Timestamp datetime) {
    try {/*from  w ww . ja 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:cs544.letmegiveexam.util.ExamDuration.java

public static long get(Date startTimestamp) {
    java.util.Date date = new java.util.Date();
    Date currentTimestamp = new Timestamp(date.getTime());
    return (currentTimestamp.getTime() - startTimestamp.getTime()) / (60 * 60);
}

From source file:Main.java

public static String getFormatDateTimeDesc(long longDate) {
    return new Timestamp(longDate).toString().substring(0, 19);
}