请教个问题,先谢了哈!我从jsp页面上获取了一串字符串,如:Tue May 11 00:00:00 GMT 2010,本来是个日期型的,现在传到后台来了,是个字符串,我怎么转变长日期型呢?

解决方案 »

  1.   

    在jsp里面也可以用javascript语言啊,传到后台以后解析一下啊,用日期定义啊。
      

  2.   

    var s = 'Tue May 11 00:00:00 GMT 2010';
    var d = new Date(s);
    alert(d);
      

  3.   

                    String date = request.getParameter("date");//接受页面传过来的日期
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
    Calendar calendar = Calendar.getInstance();

    date = date.replace("/","-");
    Date accountingPeriod = df.parse(date);
    calendar.setTime(accountingPeriod);
    year = calendar.get(calendar.YEAR);
    month = calendar.get(calendar.MONTH)+1;
    System.out.println("-------------------"+month);
      

  4.   

    本来日期型的 先格式化到你要的形式再 拿来使用何必再jsp页面处理,一般jsp页面只做显示。
      

  5.   

                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    Date date = new Date("Tue May 11 00:00:00 GMT 2010");
    String parsetime = sdf.format(date);不知道是不是lz想要的?