Convert Date/Time for given Timezone - java

前端 未结 16 2438
孤城傲影
孤城傲影 2020-11-22 12:36

I want to convert this GMT time stamp to GMT+13:

2011-10-06 03:35:05

I have tried about 100 different combinations of DateFormat, TimeZone,

16条回答
  •  日久生厌
    2020-11-22 13:07

    To find duration or time interval with two different time zone

    import org.joda.time.{DateTime, Period, PeriodType}
    
    val s1 = "2019-06-13T05:50:00-07:00"
    val s2 = "2019-10-09T11:30:00+09:00"    
    
    val period = new Period(DateTime.parse(s1), DateTime.parse(s2), PeriodType dayTime())
    
    period.getDays
    period.getMinutes
    period.getHours
    

    output period = P117DT13H40M

    days = 117
    minutes = 40
    hours = 13
    

提交回复
热议问题