小编Kar*_*azz的帖子

Calculating the time difference between two time stamp object - java

I am having java.sql.date and java.sql.time objects, I need to find the time duration between the dates.

So i am creating java.sql.timestamp object by using above date and time object

  Timestamp timestamp1 = new Timestamp(StartDate.getYear(),
        StartDate.getMonth(), StartDate.getDay(),
        StartTime.getHours(), StartTime.getMinutes(), 00,
        00);
Run Code Online (Sandbox Code Playgroud)

Here is mycode

String date = "2010-01-05";
    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
    java.util.Date date3 = null;
    try {
        date3 = sdf1.parse(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    Date StartDate = new Date(date3.getTime());
    System.out.println("Date " + StartDate);

    String date2 …
Run Code Online (Sandbox Code Playgroud)

java time timestamp date

3
推荐指数
1
解决办法
6878
查看次数

标签 统计

date ×1

java ×1

time ×1

timestamp ×1