举例:int month;
month=1  显示的是01
month=2  显示的是02
month=3  显示的是03
......for(int month=12;month>=1;month--)
  {
  if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
  {
  for(int day=1;day<=31;day++)
  {
   System.out.print("<OPTION value=\""+year+"-"+month+"-"+day+"\">"+ND[i]+month+"月"+day+"日"+"</OPTION>");
  }
  }
即2008年1月1日显示的格式为 2008-01-01

解决方案 »

  1.   

    public static void main(String[] args) throws Throwable {
         String pattern="00"; 
         java.text.DecimalFormat df = new java.text.DecimalFormat(pattern); 
         System.out.println(df.format(1));
        }
      

  2.   

    大方向错了LZ日期操作 格式化用SimpleDateFormateg:
    public static String getDate(){
    Calendar  day = Calendar.getInstance();
    //格式化
    SimpleDateFormat  dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    return (String)dateFormat.format(day.getTime());
    }
    public static void main(String[] args) {
    System.out.print(getDate());
    }输出
    2009-05-26
      

  3.   

    同意楼上的.用DataFormat接口操作.