java - Android : date format in a String -
Due to the format of these dates, there is a problem sorting my date.
I receive the date:
last calendar c = calendar.Ast Instance (); Mayer = C. Gate (Calendar: IEER); MMonth = c.get (calendar .mONTH); Mday = c.get (Calendar DAY_OF_MONTH); And I create the string with these values. dateRappDB = (new stringbuilder () .append (mYear) .append (".") Append (MMONTH + 1). APPEND ("."). APPEND (MDA). APPEND "")). Toasting (); The problem is that if the month is for February then the MMOUT value is 2. Therefore dates from the months like October (10) dates before my list.
What do I need that the day and day are made like MM and DD but I do not know how to do it in my case.
Edit : I resolved the problem using a date format I It has changed:
dateRappDB = (new stringbilder) .append (mYear) .append (".") .append (mMonth + 1) .append (".") .append (MDay) .append ("")) ToString (); From From:
Date Date = New Date (MAYYAR - 1900, MM, MDA); DateFacDB = DateFormat.format ("yyyy.MM.dd", date) .toString (); And it works thanks to all of you for your help :)
An easy way to convert a date to a string is:
SimpleDateFormat simpleDate = New SimpleDateFormat (" dd / MM / yyyy "); string strDt = simpleDate.format (dt);
Comments
Post a Comment