Android Open Source - aReminder Time Util






From Project

Back to project page aReminder.

License

The source code is released under:

GNU General Public License

If you think the Android project aReminder 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 com.hodor.company.areminder.util;
/*from  w  w w  .  j  a  v  a 2 s . c om*/
/**
 * Created by PaulTR on 6/29/14.
 */
public class TimeUtil {
    private static final String TWO_DIGITS = "%02d";
    private static final String ONE_DIGIT = "%01d";

    private static String mMinutes;
    private static String mSeconds;

    private TimeUtil() {}

    private static void setTime(long time) {
        String format;

        long seconds = time / 1000;
        long hundreds = (time - seconds * 1000) / 10;
        long minutes = seconds / 60;
        seconds = seconds - minutes * 60;
        long hours = minutes / 60;
        minutes = minutes - hours * 60;
        if (hours > 999) {
            hours = 0;
        }

        if (hundreds != 0) {
            seconds++;
            if (seconds == 60) {
                seconds = 0;
                minutes++;
                if (minutes == 60) {
                    minutes = 0;
                    hours++;
                }
            }
        }

        if (minutes >= 10 || hours > 0) {
            format = TWO_DIGITS;
            mMinutes = String.format(format, minutes);
        } else {
            format = ONE_DIGIT;
            mMinutes = String.format(format, minutes);
        }

        mSeconds = String.format(TWO_DIGITS, seconds);
    }

    public static String getTimeString(long time) {
        setTime(time);
        return String.format("%s:%s", mMinutes, mSeconds);

    }
}




Java Source Code List

com.hodor.company.areminder.model.CategoryModel.java
com.hodor.company.areminder.service.TimerService.java
com.hodor.company.areminder.timer.CountDown.java
com.hodor.company.areminder.ui.CategoryAdapter.java
com.hodor.company.areminder.ui.MainActivity.java
com.hodor.company.areminder.ui.NotificationCenter.java
com.hodor.company.areminder.util.ImagesUtil.java
com.hodor.company.areminder.util.SimpleSharedPreferences.java
com.hodor.company.areminder.util.TimeUtil.java