Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.text.format.DateUtils;

import java.util.Calendar;

public class Main {
    public static String getTimeDiff(long otherTime) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        String timeDiff = DateUtils.getRelativeTimeSpanString(otherTime, currentTime, DateUtils.MINUTE_IN_MILLIS)
                .toString();
        if (timeDiff.equals("0 minutes ago")) {
            return "<1 minute ago";
        }
        return timeDiff;
    }
}