1、数字保留两位小数
java.text.DecimalFormat df =new java.text.DecimalFormat("#.00");
df.format(你要格式化的数字);
2、时间格式化
一般常用格式化类DateFormat和SimpleDateFormat的format(Date time)方法进行格式化日期.
public class SimpleDateFormat extends DateFormat
常用构造:SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");