On 2 sep, 17:17, Mike Chaliy <[email protected]> wrote:
> Hi everyone,
>
> ASP.NET JSON serialize DateTime into the following format "\/Date
> (1251877601000)\/". Pls, help parse this string into the java(GWT)
> Date object.
>
> At this time the solution I came with is native javascript parsing
> with regex, extract long.. but then I cannot push long through JSNI. I
> hope to find something better.

Let's try something:

String dateStr = "/Date(1251877601000)/";

// start by extracting the timestamp
dateStr = dateStr.substring(6, dateStr.length() - 2);
// we could have used dateStr.replace("/Date(", "").replace(")/", "")
too

// now convert this to a long
long  timestamp = Long.parseLong(dateStr);

// then to a date:
Date d = new Date(timestamp);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to