I am trying to compare user defined time in format HH:MM with current time in an infinite loop. When they are equal, some action should occur.
I have used following code
If you don't set YEAR, MONTH, DAY it starts from 1/1/1970.
So basically you need to set YEAR, MONTH, DAY to the date you like.
In your code you are creating a new Date setting only hour and minutes and leaving the other values to default.
From javadoc:
This parsing operation uses the calendar to produce a Date. All of the calendar's date-time fields are cleared before parsing, and the calendar's default values of the date-time fields are used for any missing date-time information. For example, the year value of the parsed Date is 1970 with GregorianCalendar if no year value is given from the parsing operation.