比如一个时间类型的数据:“2006-04-19 14:39:07.403”
我只想提取其中的 "04-19" 这种月份和日期 这要怎么做呢?

解决方案 »

  1.   

    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
            System.out.println(sdf.format(new Date()));
      

  2.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String str = date.toString();
    try {
    str = sdf.format(date);
    } catch (Exception e) {
    e.printStackTrace();
    }
    String[] temp = str.split("-");
    return temp[1] + "月" + temp[2] + "日";
      

  3.   

    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
    其中MM一定要大写的
      

  4.   

    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");格式化一下