put hour in date java code example
Example 1: java calendar add minutes
String myTime = "14:10";
SimpleDateFormat df = new SimpleDateFormat("HH:mm");
Date d = df.parse(myTime);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, 10);
String newTime = df.format(cal.getTime());
Example 2: java get current hour
Try using Joda Time instead of standard java.util.Date classes. Joda Time library has much better API for handling dates.
DateTime dt = new DateTime();
int month = dt.getMonth();
int hours = dt.getHourOfDay();
See this question for pros and cons of using Joda Time library.
Joda Time may also be included to some future version of Java as a standard component, see JSR-310.
If you must use traditional java.util.Date and java.util.Calendar classes, see their JavaDoc's for help (java.util.Calendar and java.util.Date).
You can use the traditional classes like this to fetch fields from given Date instance.
Date date = new Date();
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(date);
calendar.get(Calendar.HOUR_OF_DAY);
calendar.get(Calendar.HOUR);
calendar.get(Calendar.MONTH);