我记得有个函数可以转换。
这个问题我自己可以解决。
只是印象中我知道某个库的函数封装了这个功能,希望知道的同学来回答。
问这个问题不是为了投机取巧,不想动手。
也不想打着"不要重复制造轮子"的口号逃避问题。
我只是想找到当初见到的那个轮子。
天蓬老师2017-04-17 13:27:15
After looking through the code from a long time ago, I finally found it.
Not in the java sdk, it's in the Android SDK.
Thank you everyone for sharing.
import android.text.format.DateUtils;
DateUtils.getRelativeTimeSpanString(...)
ringa_lee2017-04-17 13:27:15
There is no ready-made function, wouldn’t it be easy to write one yourself?
巴扎黑2017-04-17 13:27:15
You can actually solve this problem by yourself. If you put it here, you guys really don’t want to answer it. It’s not of good quality
You can search for java time different on Google and attach the link: java time different
Or search java time difference on Baidu.
I won’t post the specific code.
ringa_lee2017-04-17 13:27:15
I don’t know about Android, but if you are interested in writing it yourself, you can refer to the Moment.js source code of javascript.
天蓬老师2017-04-17 13:27:15
There is no ready-made function like this in jdk, nor does it seem to be available in commonly used toolkits. For this kind of problem, you can first google, Baidu, Baidu search results
google search results, bring your own ladder
阿神2017-04-17 13:27:15
Just use moment, a js module: momentjs, the format function inside is very powerful
ringa_lee2017-04-17 13:27:15
You are probably talking about Timeago
...
It should be quite common for those doing web development.
Either this
https://github.com/kevinsawicki/java-timeago