I'm using android studio, I have a timepicker that the user will choose (hour and minute) I should store this information of time in a (time) object to pass it to the database how can I store the hour and minute in a time object? I hope it's clear
hourOfDay// will store the hour for what user choose .. minute //will store the minute for what user choose
pickerTime = (TimePicker)findViewById(R.id.pickertime);
Calendar now = Calendar.getInstance();
pickerTime.setHour(now.get(Calendar.HOUR_OF_DAY));
pickerTime.setMinute(now.get(Calendar.MINUTE));
pickerTime.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener(){
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
Toast.makeText(getApplicationContext(),
"onTimeChanged", Toast.LENGTH_SHORT).show();
info.setText(
"Hour of Day: " + hourOfDay + "\n" +
"Minute: " + minute);
}});
i think you need set it in the formal time in Database HH:MM
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// date is final String variable
date = String.valueOf(hourOfDay).toString() + ":" + String.valueOf(minute).toString();
}
this is get your time in one string HH:MM
think it you need