DecimalFormat df=new DecimalFormat("0.00");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
float temp1=(float)file.getLen()/1024;
if(temp1<1024){
System.out.println(df.format(temp1)+" KB");
}else if(temp1>=1024 && temp1<1048576){
System.out.println(df.format((float)temp1/1024)+" M");
}else if(temp1>=1048576){
System.out.println(df.format((float)temp1/1048576)+" G");
}
转载于:https://my.oschina.net/mkh/blog/78301
最后
以上就是忧心水池最近收集整理的关于java中时间和浮点数格式设置的全部内容,更多相关java中时间和浮点数格式设置内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复