I have tried the following code and still get the same results:
Code1
    long start=System.currentTimeMillis();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    long finish=System.currentTimeMillis();
    Date date1 = new Date(finish- start);
    DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
    String dateFormatted = formatter.format(date1);
    System.out.println(dateFormatted);
Code2
 Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(appTerminateTime - appStartTime);
    return "session lasted for " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
 
     
    