Answer the question
In order to leave comments, you need to log in
Problems with time format in SimpleDateFormat. Where did you mess up?
The application is loaded with a schedule, and there is a method that gives a schedule item depending on the time. For convenience, I did this:
Date date = new Date();
SimpleDateFormat hour = new SimpleDateFormat("HH");
String stringHour = hour.format(date);
int intHour = Integer.parseInt(stringHour);
SimpleDateFormat minute = new SimpleDateFormat("mm");
String stringMinute = minute.format(date);
int intMinute = Integer.parseInt(stringMinute);
public int hourandminute = (intHour * 100) + intMinute;
Answer the question
In order to leave comments, you need to log in
Then you should have written:
Date date = new Date();
SimpleDateFormat hoursmins = new SimpleDateFormat("HHmm");
String stringHoursMins = hoursmins .format(date);
int hourandminute = Integer.parseInt(hoursmins );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question