0

I've got a "normal" DatePicker that is made like this:

// funzioni del datepicker
protected DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear;
        mDay = dayOfMonth;
    }
};
protected Dialog onCreateDialog(int id) {
    return new DatePickerDialog(this.getParent(),mDateSetListener,mYear, mMonth, mDay);
}

and I call showDialog(0); to expose this.

It works, but the date is in the yyyy-mm-dd format. I need to change it in the dd-mm-yyyy format. Also, can i add the hour and minutes to this?

Akshay
  • 2,506
  • 4
  • 34
  • 55
Zak
  • 591
  • 2
  • 15
  • 37
  • Search please. [Change date format link][1] [1]: http://stackoverflow.com/questions/7208769/android-how-to-change-the-datepicker-view-date-format-from-mm-dd-yyyy-to-dd-mm – Dusean Singh Aug 28 '12 at 09:51
  • Do you want to change its view date format ? – Chirag Aug 28 '12 at 09:53
  • yes. now i see Tuesday, August 28, 2012 and then the three "chooser" putted in this way: mm-dd-yyyy i want to see Martedì, 28 agosto, 2012 and then the three "chooser" putted in this way: dd-mm-yyyy – Zak Aug 28 '12 at 09:55
  • uao, wait: it's system-language dependant! so i'm ok. – Zak Aug 28 '12 at 09:58
  • i need only to add hour and second – Zak Aug 28 '12 at 09:58

1 Answers1

1

// Converting Date format from (YYYY_MM-DD) to (DD-MM-YYYY)

private String convertDate(String cdate)
{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat postFormater = new SimpleDateFormat("dd-MM-yyyy");
Date convertedDate;    
convertedDate = dateFormat.parse(cdate);
cdate = postFormater.format(convertedDate);
return cdate;
}
Rajesh Rajaram
  • 3,271
  • 4
  • 29
  • 48