Wednesday, April 18, 2012

Displaying date in a double digit format

I am having trouble displaying the date in a double digit format. I want it to be so that when the day or the month is a single digit example: 4 It would display 04. I'm having trouble comming up with the logic for it, if somebody can help me I would be really greatful. Thanks in Advanced



Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int day = c.get(Calendar.DAY_OF_MONTH);
int month = c.get(Calendar.MONTH);

if (month % 10 == 0) {

Place = 0 + month;
}
String Dates = year + "-" + Place + "-" + day;
Date.setText((Dates));




No comments:

Post a Comment