I have a problem with my Datapicker
i use the code for getting date,month & year shown below
DatePicker datePicker;
datePicker = (DatePicker) findViewById(R.id.dateselect);
int day = datePicker.getDayOfMonth();
int month= datePicker.getMonth() + 1;
int year = datePicker.getYear();
but when i print the date it shows the value 7 not 07 and for month it shows the value 2 not 02
I want these integer data in a date format ie; eg: 02-02-2013, 24-12-2013
Is there any possible way????
public String checkDigit(int number)
{
return number<=9?"0"+number:String.valueOf(number);
}
basic use:
month=checkDigit(month);
input 7
output 07
String date=checkDigit(monthOfYear+1)+"/"+checkDigit(dayOfMonth)+"/"+year;