Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

DateTime format not formatting correctly

  • 11-03-2013 12:30AM
    #1
    Closed Accounts Posts: 6,075 ✭✭✭


    I have a date/time format in XML and I'm trying to unmarshall the values as follows:

    2013-03-17T19:12:14Z -> 2013-03-17 19:12 +0100

    I have used Yoda DateTime and a DateTime adapter class to override the unmarshalling. The datetime format is coming out weird, as follows:

    {"iMillis":1363510800000,"iChronology":{"iBase":{"iBase":{"iBase":{"iMinDaysInFirstWeek":4}},"iParam":{"iZone":{"iTransitions":[-9223372036854775808,-3852662325000,-1691964000000,-1680472800000,-1664143200000,-1650146400000,-1633903200000,-1617487200000,-1601848800000,- etc etc.


Comments

  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    I have a date/time format in XML and I'm trying to unmarshall the values as follows:

    2013-03-17T19:12:14Z -> 2013-03-17 19:12 +0100

    I have used Yoda DateTime and a DateTime adapter class to override the unmarshalling. The datetime format is coming out weird, as follows:

    {"iMillis":1363510800000,"iChronology":{"iBase":{"iBase":{"iBase":{"iMinDaysInFirstWeek":4}},"iParam":{"iZone":{"iTransitions":[-9223372036854775808,-3852662325000,-1691964000000,-1680472800000,-1664143200000,-1650146400000,-1633903200000,-1617487200000,-1601848800000,- etc etc.

    Yoda? You mean joda.. right?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    ChRoMe wrote: »
    Yoda? You mean joda.. right?

    Ya :) Typo.


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    ChRoMe wrote: »
    Yoda? You mean joda.. right?

    Are you familiar with Joda time?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    I was unable to figure out the answer so I've tried the following:
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm Z");
        DateTime dateTime = new DateTime(v);
        long dateTimeMiliSec = dateTime.getMillis();
        Date date = new Date(dateTimeMiliSec);
    
        return sd.format(date);
    

    So 2013-03-17T09:00:00Z converts to 2013-03-17 09:00 +0000


Advertisement