Java – joda time days since the era

I have a question, @ L_ 419_ The number of days since epoch returned by 0 @ library changes according to the date I entered If I enter 2012-05-14 22:00:00 and 2012-05-14 02:00:00, I will get the same result because they are on the same day Here is my code

try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = sdf.parse("2013-05-03 07:00:00");
        Date date2 = sdf.parse("2013-05-03 23:30:00");


        MutableDateTime epoch = new MutableDateTime();
        epoch.setDate(0); //Set to Epoch time
        System.out.println("Epoch: " + epoch);
        Days days1 = Days.daysBetween(epoch,new MutableDateTime(date1.getTime()));
        Days days2 = Days.daysBetween(epoch,new MutableDateTime(date2.getTime()));
        System.out.println("1) Days Since Epoch: " + days1.getDays());
        System.out.println("2) Days Since Epoch: " + days2.getDays());
    } catch (ParseException e) {
        e.printStackTrace(); 
    }
Epoch: 1970-01-01T11:09:00.414+01:00
1) Days Since Epoch: 15827
2) Days Since Epoch: 15828

Solution

Make sure you find the problem (this is in front of my own eyes:)

The above is the full content of the days since the era of Java joda time collected and sorted by the programming home for you. I hope this article can help you solve the program development problems encountered in the days since the era of Java joda time.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>