请问java中如何将一个String date="2011-04-25"转换为一个String类型的"25APR11"?谢谢!

解决方案 »

  1.   


    public class App {
    public static void main(String[] args) {
    Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy"); String result = sdf.format(date); System.out.println(result);
    }
    }
      

  2.   

    再发一个:public class App {
    public static void main(String[] args) throws ParseException {
    Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); String result = sdf.format(date); System.out.println(result);
    // 打印结果: 28Apr11
    }
    }
      

  3.   

    public static void main(String[] args) throws ParseException {
            Date date = new Date();        SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH);        String result = sdf.format(date);        System.out.println(result);
            // 打印结果: 28Apr11
        }这么写就可以了 楼上是正解
      

  4.   

    但是这里“2011-04-25”是一个String类型的参数传进函数中的,不是使用Date date = new Date()得到的一个Date类型
      

  5.   

    先把String的“2011-04-25”转成Date型
      

  6.   


    先把“2011-04-25”转成Date 
    在转成你说的那种格式。
     SimpleDateFormat sdf = new SimpleDateFormat("ddMMMyy");        String formartDate = sdf.format(date);
      

  7.   

    网上一大把   查API也行  SimpleDateFormat