public static String StringFmtMicrometer(String xyje){
DecimalFormat df = null;
if(xyje.indexOf(".") > 0)
{
if(xyje.length() - xyje.indexOf(".")-1 == 0)
{
df = new DecimalFormat("###,##0.");
}else if(xyje.length() - xyje.indexOf(".")-1 == 1)
{
df = new DecimalFormat("###,##0.0");
}else
{
df = new DecimalFormat("###,##0.00");
}
}else
{
df = new DecimalFormat("###,##0");
}
double number = 0.0;
try {
number = Double.parseDouble(xyje);
} catch (Exception e) {
number = 0.0;
}
return df.format(number);
}
public String strExtractLong(String str){
String num="";
if(StringUtils.isNotEmpty(str)){
String regEx = "[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
num= m.replaceAll("").trim();
}
return num;
}
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
}
public static Date dateAddYear(Date date ,Integer year){
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.YEAR, year);
return cal.getTime();
}
public static boolean validateNumber(String str) {
if(StringUtils.isBlank(str)) {
return false;
}
return str.matches("[+-]?[0-9]+(\\.[0-9]{1,6})?");
}
public static String dateConversionStr(Date dateTime) {
if (ObjectUtils.isEmpty(dateTime)){
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(dateTime);
}