Back to project page android-test-demo.
The source code is released under:
MIT License
If you think the Android project android-test-demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.andydyer.androidtestdemo.api; //from ww w. ja v a 2 s . com import android.text.format.DateUtils; import java.text.SimpleDateFormat; import java.util.GregorianCalendar; import java.util.TimeZone; import lombok.Getter; /** * Created by andy on 8/23/14. */ public class Event { @Getter long id; @Getter String type; @Getter Actor actor; @Getter Repo repo; @Getter String createdAt; public String getCreatedAtRelativeTime() { try { TimeZone utc = TimeZone.getTimeZone("UTC"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); format.setTimeZone(utc); GregorianCalendar calendar = new GregorianCalendar(utc); calendar.setTime(format.parse(createdAt)); return DateUtils.getRelativeTimeSpanString(calendar.getTimeInMillis(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString(); } catch (Exception e) { return createdAt; } } }