url地址解码、保留小数点后面两位数字



url地址解码类

package com.xd.intersys.actions;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class URLTransform {

    public static void main(String[] args) {
        String strTest = "q=%28%2B%28%2B%28%28%28%28%2BContent%3A%22*%22%7E16%29%29%5E10.0%29%29%29+%2B%28OriginType%3Aapp+OR+OriginType%3Ajw+OR+OriginType%3Asp+OR+OriginType%3Alt+OR+OriginType%3Axw+OR+OriginType%3Abaokan+OR+OriginType%3Awz+OR+OriginType%3Azw+OR+OriginType%3Awx+OR+OriginType%3Atb+OR+OriginType%3Abk+OR+OriginType%3Awb+OR+OriginType%3Agt%29+-OriginType%3Amg%29&fq=Published%3A%5B2016-02-10T16%3A00%3A00Z+TO+2016-03-11T15%3A59%3A59Z%5D&fq=OriginType%3A%22wz%22&projectType=unkown&group=true&group.field=PublishedDay&group.format=grouped&group.main=false&group.cache.percent=50&rows=100&shards.tolerant=true&collection=collection02%2Ccollection03%2C]";
        /* strTest = URLEncoder.encode(strTest, "UTF-8"); */

        try {
            strTest = URLDecoder.decode(strTest, "UTF-8");
        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();
        }
        System.out.println(strTest);
    }

}


保留小数点后面两位数

package com.xd.intersys.actions;

public class Snippet {
    public static void main(String[] args) {
        
    //两个整数相除结果转化为float    
    int a=5;
    int b=3;
    
    System.out.println((float) a/b);
    
    //保留小数点后两位
    java.text.DecimalFormat df=new java.text.DecimalFormat("#.##");
    double d=3.14159;
    System.out.println(df.format(d)+"%");
    }

    
}


本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1750056

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jethai/article/details/52345429
个人分类: Java/C++
上一篇Solr API例子详解
下一篇Ant自动化构建项目
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭