Java Month roundMonthUnits(final int defaultUnitValue)

Here you can find the source of roundMonthUnits(final int defaultUnitValue)

Description

Round number of units to a 'month suitable' format.

License

Open Source License

Parameter

Parameter Description
defaultUnitValue a parameter

Declaration

public static int roundMonthUnits(final int defaultUnitValue) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2005, 2016 Wolfgang Schramm and Contributors
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation version 2 of the License./*  w w  w  .  j a  v a  2  s  .c o m*/
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *******************************************************************************/

public class Main {
    /**
     * Round number of units to a 'month suitable' format.
     * 
     * @param defaultUnitValue
     * @return
     */
    public static int roundMonthUnits(final int defaultUnitValue) {

        float unit = defaultUnitValue;

        while (unit > 144) {
            unit /= 12;
        }

        unit = //
                //
                unit >= 12 ? 12 : //
                        unit >= 6 ? 6 : //
                                unit >= 4 ? 4 : //
                                        unit >= 3 ? 3 : //
                                                unit >= 2 ? 2 : //
                                                        1;
        return (int) unit;
    }
}

Related

  1. normalizeMonth(String word)
  2. paraseMonth(String yearMonth)
  3. parseMonth(final int month)
  4. ResolveMonth(String MonthToResolve)
  5. returnMonth(String month)
  6. setStatis_month(String year_month)
  7. startDaemonThread(Runnable runnable)
  8. stringToMonth(String m)
  9. toAnotherMonthColor(String value, String type)