hcg_21 于 2013.04.18 13:58 提问

``````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));
``````

3个回答

xiaoyan_12   2013.04.19 10:47

``````DecimalFormat mFormat= new DecimalFormat("00");
mFormat.format(Double.valueOf(year));
``````

`````` mFormat.setRoundingMode(RoundingMode.DOWN);
String Dates =  mFormat.format(Double.valueOf(year)) + "-" +  mFormat.format(Double.valueOf(Place)) + "-" +  mFormat.format(Double.valueOf(day));
``````
ppgl1988   2013.04.18 15:30
``````    Calendar cale = Calendar.getInstance();

SimpleDateFormat df=new SimpleDateFormat("yyyy-M-d");

``````
hiramtan   2013.04.18 17:05

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

string dayString;
if(day<10)
dayString = "0"+day;
else
dayString = day.toSring();

``````    int month = c.get(Calendar.MONTH);

if (month % 10 == 0) {

Place = 0 + month;
}
``````

String Dates = year + "-" + Place + "-" + dayString;
//String Dates = year + "-" + Place + "-" + day;
Date.setText((Dates));