常用公共代码备份

    
    /**
     * 调用应用管理中配置的参数
     * @return
     */
    public final static String getAppVal(String Key){
        AppAPI appAPI = SDK.getAppAPI();
        String val = appAPI.getProperty(appID, Key);
        return val;
    }
    
    
    public static void main(String[] args) {
        System.out.println(getDate("2017-09-01"));
    }
    
    
    /*字符串转时间*/
    public static Date getDate(String dateStr){
         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
         Date date =null;
         try {
            date = dateFormat.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
    /*时间转日期*/
    public static String getDateStr(Date date){
         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         String str =null;
         str = dateFormat.format(date);
        return str;
    }
    /*毫秒数值,转化为日期*/
    public static String getDateTime(Long long1){
        Date date = new Date();  
        date.setTime(long1);  
       return getDateStr(date);
    }



    /**
     * 字符串转换   A,B,C 转  'A','B','C'
     * @param str 
     * @return
     */
    public static String getArrAtr(String str){
         String[] strArr =str.split(",");
         for (int i = 0; i < strArr.length; i++) {
             if (i==0) {
                 str="'"+strArr[i]+"'";
            }else {
                str+=",'"+strArr[i]+"'";
            }
        }
         return str;
    }



原文地址:https://www.cnblogs.com/renpei/p/9365225.html