Java Number Range Create range(int unit)

Here you can find the source of range(int unit)

Description

Don't get excited.

License

Open Source License

Declaration

static int range(int unit) throws Exception 

Method Source Code

//package com.java2s;
/*  Copyright (c) 2016// ww w.j  a v  a2 s  .c  om
 *  by Bj?nd, Inc., Boston, MA
 *
 *  This software is furnished under a license and may be used only in
 *  accordance with the terms of such license.  This software may not be
 *  provided or otherwise made available to any other party.  No title to
 *  nor ownership of the software is hereby transferred.
 *
 *  This software is the intellectual property of Bj?nd, Inc.,
 *  and is protected by the copyright laws of the United States of America.
 *  All rights reserved internationally.
 *
 */

public class Main {
    public final static int SECONDS = 0;
    public final static int MINUTES = 1;
    public final static int HOURS = 2;
    public final static int DAYS = 3;
    public final static int MONTHS = 5;
    public final static int YEARS = 6;

    /**
     * Don't get excited.  It's only an approximation 
     */
    static int range(int unit) throws Exception {
        switch (unit) {
        case YEARS:
            return Integer.MAX_VALUE;
        case MONTHS:
            return 12;
        //        case WEEKS:
        //            return 4;
        case DAYS:
            return 30;
        case HOURS:
            return 24;
        case MINUTES:
            return 60;
        case SECONDS:
            return 60;
        default:
            throw new Exception("Invalid unit: " + unit);
        }
    }
}

Related

  1. range(int start, int end, int step)
  2. range(int start, int length)
  3. range(int start, int length, int step)
  4. range(int start, int stop)
  5. range(int startValue, int endValue)
  6. range(int v, int min, int max)
  7. range(int value, int min, int max)
  8. range(Integer from, Integer to)
  9. range(long array[])