package com.sheep.jiuyan.samllsheep.utils;

import android.text.TextUtils;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2018/1/31.
 */

public class StringUtils {

    public static String  strToMoney(String  str){
        if(TextUtils.isEmpty(str)||str.equals("0"))  {
            return "0";
        }
        DecimalFormat df = new DecimalFormat("###,###.##");
        NumberFormat nf = NumberFormat.getInstance();
        String  money="0";
        try
        {
            money= df.format((nf.parse(str)));
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }
        return money;



    }


    public static boolean checkMobileNum(String mobiles) {
        Pattern p = Pattern
                .compile("^((13[0-9])|(15[^4,\\D])|(18[0,0-9])|(17[0,3,5,6,7,8])|14[5,6,8,7,9])\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();

    }






}
