I am getting wrong time between two dates in Joda-Time

前端 未结 1 1640
谎友^
谎友^ 2021-01-29 15:36

I am getting incorrect results whatever I do. Could anyone give me some advise please :).

Here is the code of my program the is responsible for getting the time between

相关标签:
1条回答
  • 2021-01-29 16:30

    Your bug is in these two lines:

                int daysoutput = Days.daysBetween(datestartdaytime, datestartdaytime).getDays() % 30;
                int hoursoutput = Hours.hoursBetween(datestartdaytime, datestartdaytime).getHours() % 24;
    

    You intended to use dateenddaytime as the second argument:

                int daysoutput = Days.daysBetween(datestartdaytime, dateenddaytime).getDays() % 30;
                int hoursoutput = Hours.hoursBetween(datestartdaytime, dateenddaytime).getHours() % 24;
    
    0 讨论(0)
提交回复
热议问题