Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

DateTime format not formatting correctly

Options
  • 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 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