Java BigDecimal getId(BigDecimal total, BigDecimal step)

Here you can find the source of getId(BigDecimal total, BigDecimal step)

Description

get Id

License

Open Source License

Declaration

public static BigDecimal getId(BigDecimal total, BigDecimal step) 

Method Source Code


//package com.java2s;
/*//from ww  w. jav a  2s  .c  o  m
 * Copyright(C) 2011-2012 Alibaba Group Holding Limited
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  Authors:
 *    wentong <wentong@taobao.com>
 */

import java.math.BigDecimal;
import java.util.Random;

public class Main {
    private static final Random RANDOM = new Random();

    public static BigDecimal getId(BigDecimal total, BigDecimal step) {
        return step.multiply(new BigDecimal(RANDOM.nextInt(total.intValue())));
    }

    public static int nextInt(int i) {
        return RANDOM.nextInt(i);
    }
}

Related

  1. getEndTimeByManDay(Date serviceStartTime, BigDecimal manDay)
  2. getFloatingPoint(Console console, Function validator)
  3. getFormattedBigDecimal(BigDecimal value)
  4. getFraction(BigDecimal b)
  5. getFractionalPart(BigDecimal value)
  6. getIntLength(BigDecimal val)
  7. getIntValue(BigDecimal b)
  8. getLength(BigDecimal v)
  9. getLet(BigDecimal nl, BigDecimal el)