4

I need a method to convert .NET Date in Java Date, currently if I try to convert this date retrieved from SharePoint 2010 with json:

/Date(-2209161600000)/

CONVERSION TEST:

String input = "/Date(-2209161600000)/";
Date date = new Date(Long.parseLong(input.substring(6,input.length()-2)));

I obtain:

Sat Dec 30 01:00:00 CET 1899

What is the current way in order to convert the .net date? What are the long milliseconds to add (or subtract) in order to obtain the java milliseconds?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Cisco
  • 532
  • 1
  • 8
  • 24
  • 1
    Well, what date is it supposed to be? Seeing how it's a **negative** timestamp, a time in the past doesn't seem terribly wrongas a result - it's possible the data in Sharepoint is wrong to begin with. (It looks to me like it's midnight, Jan 1st, 1900 – i.e. 00-01-01 00:00, shifted to a different timezone.) – millimoose Jan 18 '14 at 17:22
  • 1
    well I would serialize the .net date into some standard datetime representation, like ISO-8601, and from there you can use it in any other application/language etc. – kmera Jan 18 '14 at 17:30
  • @millimoose : Yes, correct, I've verified on SHarepoint and the date is wrong: 1899-12-30T00:00:00 ...so the conversion is correct!! I thought that something change between Unix and .Net.... – Cisco Jan 18 '14 at 17:34

0 Answers0