Coder Social home page Coder Social logo

Comments (13)

curioustechizen avatar curioustechizen commented on June 4, 2024 1

If you see "in 23 hours" then probably the time you get from server is in the future. I can't think of any other explanation.

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024 1

@thamer898 You are responsible for ensuring that the value you pass to setReferenceTime() is in the appropriate time zone. This library uses System.currentTimeMillis() method to get the current time on the Android device and compare it against the reference time you passed it. Since System.currentTimeMillis() is always in UTC time zone, you could try converting the time you get from your server into UTC (i.e., time since epoch) format and then passing it to setReferenceTime()

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024 1

@thamer898 You have 2 options:

  1. Your server always returns the time in UTC
  2. Your server returns time in whatever time zone it is in and in your app you convert it to UTC before setting it using setReferenceTime

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024

@thamer898 could you provide some sample code?

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

Hello

please see this code

//created at a value from server as an example it's value "2016-04-22T20:21:43.405Z"

RelativeTimeTextView v = (RelativeTimeTextView) convertView.findViewById(R.id.timestamp); //Or just use Butterknife!
v.setReferenceTime(createdAt.getTime());

Regards

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

Hello

@curioustechizen any updates ?

Regards

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024

You'll have to provide a little more information I'm afraid. What did you expect the output to be? What was the actual time on the phone when you set the server time?

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

Hello

this is the message delivery time from server : Sun Apr 24 23:01:18 EEST 2016
so i get the time by this variable long now = new Date().getTime();

after that this is the calculation method
String Date = DateUtils.getRelativeTimeSpanString(
createdAt.getTime(),
now,
DateUtils.SECOND_IN_MILLIS).toString();

Regards

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

Hello

i want to display a message time like "just now" , 1 minute ago and so on .

Regards

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

great what is the best time zone for my server that i should consider it ? kindly advice

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

@curioustechizen thank you very much this is a problem from my server i change the time zone to be +3 and i solved the problem but how it will be for the countries for multiple time zones ?

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

@curioustechizen right now am using a windows server 2012 r2 but right now am confused about the best time zone for different regions around the world do you have and advice about suitable time zone for that ?

from android-ago.

thamer898 avatar thamer898 commented on June 4, 2024

Hello @curioustechizen

Yes i saved a value as UTC in my server so is it fit all time zones ?

Regards

from android-ago.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.