Suppose I change the system date and time. When I use Date
or Calendar
objects in Java, I get the changed/modified time which is not correct.
I need the exact local time, not the modified time.
long millis = System.currentTimeMillis();
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
Date date = new Date(millis);
System.out.println(dateFormat.format(date));