package com.tzld.piaoquan.growth.common.utils;

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

public class RandomUtil {

	public static final String ALLNUMBER = "0123456789";  
	public static final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";  
	public static final Integer FIXLENG=18;
    /** 
     * 返回一个定长的随机字符串(只包含大小写字母、数字)
     *  随机字符串长度
     * @return 随机字符串 
     */  
    public static String generate18String() {  
        StringBuffer sb = new StringBuffer();  
        Random random = new Random();  
        for (int i = 0; i < FIXLENG; i++) {  
            sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));  
        }  
        return sb.toString();  
    } 
    
    public static void main(String[] args) {
		//System.out.println(generate18String())
        String proportion="0.01";
        Long price=150l;
        Double incomeMoney=price*(Double.valueOf(proportion));
        System.out.println(incomeMoney);


        BigDecimal b = new BigDecimal(incomeMoney);
        Long t = b.setScale(0,BigDecimal.ROUND_HALF_UP).longValue();
        System.out.println(t);

    	
	}
    
    public static String generateString(int length) {  
        StringBuffer sb = new StringBuffer();  
        Random random = new Random();  
        for (int i = 0; i < length; i++) {  
            sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));  
        }  
        return sb.toString();  
    }
    
    public static String generateNumber(int length) {  
        StringBuffer sb = new StringBuffer();  
        Random random = new Random();  
        for (int i = 0; i < length; i++) {  
            sb.append(ALLNUMBER.charAt(random.nextInt(ALLNUMBER.length())));  
        }  
        return sb.toString();  
    } 
    
    public static String getRandomUUIDStr() {
		return UUID.randomUUID().toString().replaceAll("-", "")+Calendar.getInstance().getTimeInMillis();
	}

}
