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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值