java开发

1、Float取整

long warning;
float fwarning = 0f;
fwarning = total*0.34/100;
warning = new Float(fwarning + 0.5f).longValue();

2、eclipse 经常弹出console的问题

设置方法:在window->preperences->Run/Debug->console 中,把'show when program writes to standard out'的勾去掉就可以了 

3、获取时间戳 

System.currentTimeMillis()

4、正则表达式使用

复制代码

import java.util.regex.Matcher;
import java.util.regex.Pattern;

String pstr = "/p/";
Pattern p = Pattern.compile(pstr);
Matcher m = p.matcher("/p/3333");
System.out.println(m.find() ? m.group(1) : "nothing");
复制代码

5、Double类型保留两位小数

DecimalFormat df=new DecimalFormat(".##");
double d=1252.2563;
String st=df.format(d);
System.out.println(st);
原文地址:https://www.cnblogs.com/779084229yyt/p/8405701.html