如何将Date对象从Flex传递给JSP Servlet?

时间:2021-10-08 07:53:36

I am passing some parameters as POST to a Servlet from my Flex WebApplication. I am able to pass and retrieve strings properly.

我将一些参数作为POST从Flex WebApplication传递给Servlet。我能够正确地传递和检索字符串。

I used new Date().getTime() in my flex code and tried passing the timestamp variable hoping to parse it at the servlet and convertit into a java.util.Date object. But i am getting a NumberFormatException when i try to parse the variable from the string that i got from request.getParameter.

我在我的flex代码中使用了新的Date()。getTime()并尝试传递timestamp变量,希望在servlet中解析它并将其转换为java.util.Date对象。但是当我尝试从request.getParameter获取的字符串中解析变量时,我得到一个NumberFormatException。

Any solutions?

有解决方案?

1 个解决方案

#1


1  

I think you are not converting String to long in Java IF so Please try

我认为你没有在Java IF中将String转换为long,所以请尝试

String strDateinmilliseconds = request.getAttribute("FlexMilliseconds");

long dateinmilliseconds = Long.valueOf(strDateinmilliseconds);

Date resultdate = new Date(dateinmilliseconds);

SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");

System.out.println(sdf.format(resultdate));

Hopes that helps

希望有所帮助

#1


1  

I think you are not converting String to long in Java IF so Please try

我认为你没有在Java IF中将String转换为long,所以请尝试

String strDateinmilliseconds = request.getAttribute("FlexMilliseconds");

long dateinmilliseconds = Long.valueOf(strDateinmilliseconds);

Date resultdate = new Date(dateinmilliseconds);

SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");

System.out.println(sdf.format(resultdate));

Hopes that helps

希望有所帮助