我是靠谱客的博主 忧心水池,这篇文章主要介绍java中时间和浮点数格式设置,现在分享给大家,希望可以做个参考。

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中时间和浮点数格式设置内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(119)

评论列表共有 0 条评论

立即
投稿
返回
顶部