Date without timezone

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HazuRek
    Junior Member
    • Aug 2013
    • 21

    #1

    Date without timezone

    Good day!

    Is it made on purpose that date has format without timezone: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'?
    The problem is that when converting to Date object (using Gson library in Java) the time become incorrect. E.g. when converting "2013-08-29T14:44:00.000Z" the result Date object has time "Thu Aug 29 14:44:00 GMT+04:00 2013" which is incorrect.
    Last edited by HazuRek; 29-08-2013, 01:59 PM. Reason: 1
  • AlgoTrader
    Junior Member
    • Mar 2012
    • 243

    #2
    Are you aware that all Betfair dates are timezone-less? It means, that it is up to you which time zone to convert time to.

    Press F12 in Chrome, select console tab and type

    Code:
    new Date("2013-08-29T14:44:00.000Z")
    Thu Aug 29 2013 18:44:00 GMT+0400 (Moscow time (summer))
    My browser just translated the time to the zone it likes. That's GUI's role to present dates in your local timezone, internally all dates are in GMT.

    Check your lib, the problem is certainly there, you probably misuse it
    Betfair Bots Made Easy

    Comment

    • HazuRek
      Junior Member
      • Aug 2013
      • 21

      #3
      The "problem" is not with concrete lib, it is with standart JavaSE class SimpleDateFormat.

      Code:
      	@Test
      	public void testSimpleDateFormat() throws ParseException
      	{
      		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
      		String text = "2013-08-29T14:44:00.000Z";
      		System.out.println(sdf.parse(text));
      	}
      The output is:
      Code:
      Thu Aug 29 14:44:00 GMT+04:00 2013

      Comment

      • AlgoTrader
        Junior Member
        • Mar 2012
        • 243

        #4
        Converting ISO8601-compliant String to java.util.Date
        http://stackoverflow.com/questions/2...java-util-date

        Yep, it is painful in Java to deal with ISO 8601 dates
        Betfair Bots Made Easy

        Comment

        Working...
        X