I am trying to create a time interval, as the starting point is the current time and the minimum and maximum values are calculated by a special variable which is set by the user (upperBound). So the code looks like:
private static int upperBound = 1440;
.....
Calendar calendar = Calendar.getInstance();
System.out.println("Now:\t\t\t" + calendar.getTime());
calendar.set(Calendar.MINUTE, -upperBound);
System.out.println("After the change:\t" + calendar.getTime());
and the output is:
Now: Mon Jan 27 14:53:42 EET 2014
After the change: Sun Jan 26 14:00:42 EET 2014
But I expect to be (after the change): Sun Jan 26 14:53:42 EET 2014
What is wrong here?
You should use
add()
method, notset