Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetText with Date String ? #19

Closed
amaydiam opened this issue Jul 7, 2015 · 1 comment
Closed

SetText with Date String ? #19

amaydiam opened this issue Jul 7, 2015 · 1 comment

Comments

@amaydiam
Copy link

amaydiam commented Jul 7, 2015

How setText if I have String Date like "2015-08-02 01:01:50" ?

@curioustechizen
Copy link
Owner

@amaydiam Currently, the library expects the date in milliseconds since epoch format - for example, the format returned by System.currentTimeMillis(). If you receive the date in String format, you need to first convert it to a long. Something along the following lines should work (Note:- This code is not tested*

//Declare SDF as a static somewhere
static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

//Then, wherever you receive the String date, do this
long dateAsLong = DATE_FROMAT.parse(stringDate).getTime();
relativeTimeTextView.setReferenceTime(dateAsLong);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants