package com.miniframe.tools; import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class XIDataUtils { public static String format2Dot = "%.2f"; public static String format5Bit = "%05d"; //逗号分隔的字符串,转成List public static List toList(String input) { List output = new ArrayList<>(); if (StringUtils.hasLength(input) && !input.contains(",")) { output.add(input); } else if (StringUtils.hasLength(input) && input.contains(",")) { output = Arrays.asList(input.split(",")); } return output; } /** * 将数据扩大100倍 * * @param rawData * @return */ public static Integer multiply100(String rawData) { return new Double(Double.valueOf(rawData) * 100).intValue(); } /** * 获取int值 * * @param s */ public static int getInt(String s) { try { return Integer.parseInt(s); } catch (Exception e) { e.printStackTrace(); } return -1; } /** * 获取long值 * * @param s */ public static long getLong(String s) { try { return Long.parseLong(s); } catch (Exception e) { e.printStackTrace(); } return -1; } /** * 获取double值 * * @param s */ public static double getDouble(String s) { try { return Double.parseDouble(s); } catch (Exception e) { e.printStackTrace(); } return -1; } }