我格式化如下我的約會:JodaTime日期格式問題
String inputDateString = aMessage.getString("updated_at");
DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
DateTime date = fmt.parseDateTime(inputDateString);
DateTime now = new DateTime();
Period period = new Period(date, now);
PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendSeconds().appendSuffix(" seconds ago\n")
.printZeroNever()
.toFormatter();
String elapsed = formatter.print(period);
dateTextView.setText(elapsed);
我希望能夠證明:
3 seconds ago if the period is less than 60 seconds
3 minutes ago if the period is less than 60 minutes
3 hours ago is the period is less than X hours
3 days ago if the period is less than X days
等等,等等
我怎樣才能實現這個?
似乎我無法將其與int進行比較。編譯時錯誤 '運算符<未定義爲參數類型分鐘,int' – 2011-05-24 16:57:53
您如何看待'org.joda.time.Minutes'實例是否代表小於60分鐘?看看[API](http://joda-time.sourceforge.net/api-release/org/joda/time/Minutes.html),看看你是否可以自己解決(這並不困難) ! – 2011-05-24 17:01:38