JodaTime PeriodFormat,只有1场的经过时间 [英] JodaTime PeriodFormat, Elapsed time with only 1 Field

查看:167
本文介绍了JodaTime PeriodFormat,只有1场的经过时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如




  • 期间= 1年4个月和5天==>结果=1年前

  • 期间= 3个月5天==>结果=3个月前

  • 期间= 4小时5分钟==>结果=4小时前



所以我只想要最高的可用字段。

解决方案

在Joda-Time中没有办法做到这一点,所以你会有手动测试每个字段。


How can we display the elapsed time with only 1 field.

For example

  • Period = 1 Year 4 Months and 5 Days ==> Result = "1 Year ago"
  • Period = 3 Months 5 Days ==> Result = "3 Months ago"
  • Period = 4 Hours 5 Minutes ==> Result = "4 Hours ago"

So i just want the highest available field.

解决方案

There is no method in Joda-Time to do this, so you will have to test each field in turn manually.

这篇关于JodaTime PeriodFormat,只有1场的经过时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆