I get the date string from the server in this format: 2019-04-11 02:43:40
How can you compare the received date from the server, with the current date and time and show it in the application in the format: 6 минут назад
or 8 часов назад
?
PS: The server records the date in the Moscow time zone. (GMT + 3)
PPS: I suppose that you first need to get the date from the device "in the device time zone", for example: 2019-04-11 02:45:00 GMT+4
, but then I don’t understand what to do = I don’t understand .. or there are ready-made libraries that can do it ??
And if my assumption is wrong, then correct me))
UPDATE
I can not get Moscow time using the Joda-time library:
DateTimeZone timeZone = DateTimeZone.forID("Europe/Moscow"); DateTime nowMOSCOW = DateTime.now(timeZone);
I get in the logs:
I/System.out: SSS: 2019-04-10T23:01:55.869+03:00
Not quite clear, the library and this code somehow depends on the time on the device? Or regardless of how much time is installed on my device and in what time zone I am, should I get Moscow time ??
6 минут назад
get throughSystem.currentTimeMillis()-дата поста или что у вас
- Dred