I’m having trouble getting the right format here. I’m trying to get a proper date from my android date picker to shove into a date object.
For example:
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
public void onTimeSet(TimePicker view, int hourOfDay, int minute)
Those event handlers will give me: 2011, 7, 5 10,30 (if the date was August 5th, 2011 and the time was 10:30) Where do I get Am/Pm in Android?
I’m doing this but its not working right:
Date date = new Date(year,monthOfYear,dayOfMonth,hourOfDay,minute);
I need to accomplish the Android equivalent of this blackberry code. Blackberry date picker graciously provides a date object (rather than raw integers):
public void run() {
DateTimePicker datePicker = DateTimePicker.createInstance();
// Set the max time to 24 hours into the future. This allows for selecting clips
// across time zones, but prevents the user from wandering off into no-mans' land.
Calendar maxDateTime = Calendar.getInstance();
maxDateTime.setTime(new Date(System.currentTimeMillis() + 24*3600*1000));
datePicker.setMaximumDate(maxDateTime);
if (datePicker.doModal())
{
Calendar selectedDate = datePicker.getDateTime();
Date beforeDate = selectedDate.getTime();
ClipStore.getInstance().getClips(camera, beforeDate);
}
}
Use a Calendar :
The hour of day goes from 0 to 23.