English 中文(简体)
Joda 日期 1. 时间差异
原标题:Joda DateTime difference with PeriodFormat like 1:30
  • 时间:2012-05-10 21:26:23
  •  标签:
  • jodatime

在两个日期之间有时间间隔的Im。

 Period p = new Period(startDate, endDate,
                PeriodType.standard().withSecondsRemoved().withMillisRemoved());

        return PeriodFormat.getDefault().print(p);

这使我以“1小时30分钟”为形式。

我怎么能找到像“1:30”或“:15”这样的东西?

I suppose I could do something like:

public static int getHoursDifference(DateTime startDate, DateTime endDate) {
        Period p = new Period(startDate, endDate);
        return p.getHours();
    }

同样,时间为分钟,然后又会合......?

最佳回答
问题回答

暂无回答




相关问题
Jodatime - Custom Chronology

I would like to calculate a duration whereas 1 day will consist of 8 hours. Is creating a new Chronology is the right approach ? I did try to create a custom Chronology and override the assemble ...

Can I parse relative times with JodaTime?

I d love to be able to parse relative strings like now and yesterday and get JodaTime DateTimes. Is it possible? DateTimeFormat.forPattern and doesn t seem to support English relative times and I don ...

How to query a date in HQL (Hibernate) with Joda Time?

I am sure that someone familiar with HQL (I am myself a newbie) can easily answer this question. In my Grails application, I have the following domain class. class Book { org.joda.time.DateTime ...

Joda Time gives wrong time zone

I m using the Joda time (1.6) libraries and it keeps returning DateTime objects with the wrong time zone, British Summer Time instead of GMT. My Windows workstation (running JDK 1.6.0_16) thinks it s ...

Jodatime : what is there to keep up to date?

I read (dont t know where anymore, but see here) when using Jodatime you have to keep files up to date. What kind of files? Why is that?

热门标签