有没有办法把
2011-01-01变成 2011-1-1
2011-11-01变成 2011-11-1
就是把月份和日期的0去掉

解决方案 »

  1.   


       public static void main(String[] args) throws Exception {
          SimpleDateFormat from = new SimpleDateFormat("yyyy-MM-dd");
          SimpleDateFormat to = new SimpleDateFormat("yyyy-M-d");
          System.out.println(to.format(from.parse(("2011-11-01"))));
       }
      

  2.   

    SimpleDateFormate解析为时间然后逐一获取年 月 日