I am reading date (in variable "last_time") from a website in the format: MM-dd HH:mm, I want to get this date, parse it, which I did in this code. Then I want to know how much time passed, till now. I am trying to get the difference between the time read and the current time in milliseconds, but I am getting the wrong value when I compare it with Epoch time converters. Can I customly include the year and then parse it?
Calendar date = Calendar.getInstance();
date.setTime(new SimpleDateFormat("MM-dd HH:mm").parse(last_time)); // Parse into Date object
date.set(Calendar.YEAR, 2022);
var curr = date.getTimeInMillis();
long now = Calendar.getInstance().getTimeInMillis(); // Get time now
System.out.println(now);
long differenceInMillis = now - curr;
Date used: 05-12 00:19 timeInmillisec obtained after parsing: 1652329140000 expected time in millisec: 1652415544