Android Open Source - android-test-demo Event






From Project

Back to project page android-test-demo.

License

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.

Java Source Code

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;
        }
    }
}




Java Source Code List

org.andydyer.androidtestdemo.ApplicationTest.java
org.andydyer.androidtestdemo.DemoApplication.java
org.andydyer.androidtestdemo.LoginActivityTest.java
org.andydyer.androidtestdemo.MainActivityTest.java
org.andydyer.androidtestdemo.Modules.java
org.andydyer.androidtestdemo.Modules.java
org.andydyer.androidtestdemo.api.Actor.java
org.andydyer.androidtestdemo.api.ApiServiceModule.java
org.andydyer.androidtestdemo.api.ApiServiceTest.java
org.andydyer.androidtestdemo.api.ApiService.java
org.andydyer.androidtestdemo.api.AuthenticationService.java
org.andydyer.androidtestdemo.api.Event.java
org.andydyer.androidtestdemo.api.Events.java
org.andydyer.androidtestdemo.api.MockApiServiceModule.java
org.andydyer.androidtestdemo.api.MockApiService.java
org.andydyer.androidtestdemo.api.Repo.java
org.andydyer.androidtestdemo.ui.LoginActivity.java
org.andydyer.androidtestdemo.ui.MainActivity.java
org.andydyer.androidtestdemo.ui.WebViewActivity.java
org.andydyer.androidtestdemo.ui.fragments.EventListFragment.java
org.andydyer.androidtestdemo.ui.widgets.SimpleDividerItemDecoration.java