Java – use durationformatutils to format periods in a good way
•
Java
This is very effective:
out.println(DurationFormatUtils.formatPeriod( new Date().getTime(),match.getStartingTime().getTime(),"d H"));
But now I want some better formats
out.println(DurationFormatUtils.formatPeriod( new Date().getTime(),"d days H hours left"));
But as expected, the output is
Is there a simple solution to this problem?
Solution
It seems that their format is based on simpledateformatter, and the escape character is' '
So your code is like this:
"d 'days' H 'hours left'"
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
二维码