Java Base Encode toBase(long startMillis, long currentMillis, long baseMillis)

Here you can find the source of toBase(long startMillis, long currentMillis, long baseMillis)

Description

to Base

License

Open Source License

Declaration

public static long toBase(long startMillis, long currentMillis,
            long baseMillis) 

Method Source Code

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

public class Main {
    public static long toBase(long startMillis, long currentMillis,
            long baseMillis) {
        long low = downTo(currentMillis, baseMillis);
        long high = upTo(currentMillis, baseMillis);
        long ret = startMillis;
        while (ret <= low) {
            ret += baseMillis;//  w  w  w.j a va  2s.  c  o  m
        }
        while (ret >= high) {
            ret -= baseMillis;
        }
        return ret;
    }

    public static long downTo(long currentMillis, long baseMillis) {
        return currentMillis / baseMillis * baseMillis;
    }

    public static long upTo(long currentMillis, long baseMillis) {
        return downTo(currentMillis, baseMillis) + baseMillis;
    }
}

Related

  1. toBase10(final String base62)
  2. toBase10(int[] arr)
  3. toBase10(int[] arr)
  4. toBase10SuffixedString(long n)