This code works but when it converts the input into milliseconds it adds five hours. Is there a fix for this?

    ArrayList<String> timeList = new ArrayList<String>();
    Scanner in = new Scanner(System.in);
    System.out.println("Please enter time you arrived (HH:mm:ss): ");
    timeList.add(in.next());
    SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); 
    String arriveTime = timeList.get(0);
    try{
        Date date1 = format.parse(arriveTime);
        long finalTime = date1.getTime();
    }catch (Exception e) {
        System.out.println("An error occurred");
    }
1

There are 1 best solutions below

1
On BEST ANSWER

I'm going to guess you're in the Eastern time zone and are confusing EDT with GMT.