Saturday 15 May 2010

android - Formatting Date in DatePicker, Storing Date in Database -


I DatePicker that it's time to bring a date format based on user location ( I think that ). I would like to format this date so that users can select a format.

Also, I want to store this date in a database. After I use the format <'d like to use code> yyyyMMdd

is still my problem now DatePicker My date formatting

This is what I just wrote:. The

  public static class DatePickerFragment DialogFragment implements DatePickerDialog.OnDateSetListener, OnClickListener extends {@Override public discourse onCreateDialog (bundled savedInstanceState) {// picker last calendar default date c = Calendar.getInstance () Use today's date as a form; Int Year = C Gate (Calendar: IEER); Int month = c. Gate (calender.mnsh); Int day = c.get (Calendar DAY_OF_MONTH); Return new date picture diagram (getActivity (), this, year, month, day); } Public Zero onDateSet (DatePicker view, integer year, integer month, integer day) {//. "+ (Month DATEVALUE = String.valueOf user (" "+ do something with the day + went chosen by 'date + 1) +". "+ Year); date_widget.setText (DATEVALUE); {SimpleDateFormat sdfToDate = new SimpleDateFormat ( Try "YyyyMdd") or; DateDB = String.valueOf (sdfToDate.parse (dateValue)); log. ( "Date" Date dB);} catch (ParseException ex2) {ex2.printStackTrace ();}} @Override Public Zero onClick (DialogInterface dialog, integer which) {// TODO Automatically created method stub}}   

I do not think this is the best way to do this, but DatePicker works .

Only one point out of the month gives me an exception when trying to format my date:

  unseasable date: "22.6.2013" (in offset 7)    

Create a date on the date of the date with the calendar, the format to view public void onDateSet (DatePicker, int year, int month, int day) {Calendar = Calendar.getInstance () .; Calendar.set (year, month, day); Date Date = Calendar. GetTime (); }

No comments:

Post a Comment