`
Jw.mac
  • 浏览: 10460 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

【转】将原数据前补零,格式字符串

    博客分类:
  • java
 
阅读更多

 

 

/**
  * 将原数据前补零,补后的总长度为指定的长度,以字符串的形式返回
  * @param sourceDate
  * @param formatLength
  * @return 重组后的数据
  */
 public static String frontCompWithZore(int sourceDate,int formatLength)
 {
  /*
   * 0 指前面补充零
   * formatLength 字符总长度为 formatLength
   * d 代表为正数。
   */
  String newString = String.format("%0"+formatLength+"d", sourceDate);
  return  newString;
 }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics