How to add Leading Zeroes to a Number (Delphi Format)

Here's how convert (an integer) number to a string by adding an amount of leading zeroes.

Suppose you are developing a database application, and you need to operate on, let's say, a customer number, where each number needs to be exactly 10 digits "long" - but you have customer numbers of 2,4,7, etc. (<10) digits.

The AddLeadingZeroes function accepts two parameters: aNumber is the number that needs to have exactly Length characters (if less, add leading zeroes).

function AddLeadingZeroes(const aNumber, Length : integer) : string;
begin
result := SysUtils.Format('%.*d', [Length, aNumber]) ;
end;

Usage:

AddLeadingZeroes(, ) ;

Will result in a '0000002005' string value.

How to add Leading Zeroes to a Number (Delphi Format)的更多相关文章

  1. Bash: Removing leading zeroes from a variable

    old=" # sed removes leading zeroes from stdin new=$(echo $old | sed 's/^0*//')

  2. spring boot 当参数传入开头多个0时,报错:JSON parse error: Invalid numeric value: Leading zeroes not allowed

    原因是: Jackson解析json配置的问题 在配置文件中设置下: spring.jackson.parser.allow-numeric-leading-zeros=true

  3. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  4. Codeforces 622B The Time 【水题】

    B. The Time time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  5. oracle 日期格式化 TO_CHAR (datetime) 修饰语和后缀

    Datetime Format Element Suffixes Suffix Meaning Example Element Example Value TH Ordinal Number DDTH ...

  6. Educational Codeforces Round 7 B

    Description You are given the current time in 24-hour format hh:mm. Find and print the time after a  ...

  7. codeforces 622B B. The Time

    B. The Time time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  8. poj3301 三分

    Texas Trip Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4998   Accepted: 1559 Descri ...

  9. poj 3301 Texas Trip(几何+三分)

    Description After a day trip with his friend Dick, Harry noticed a strange pattern of tiny holes in ...

随机推荐

  1. Linux 并发链接数

    并发数查看   查看 TCP 协议连接数 netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' SYN_RECV # ...

  2. oracle用户密码过期!the password has expired

    Oracle提示错误消息ORA-28001: the password has expired,是由于Oracle11G的新特性所致, Oracle11G创建用户时缺省密码过期限制是180天(即6个月 ...

  3. [CEOI2015 Day2]世界冰球锦标赛 (双向搜索)

    题目描述 [CEOI2015 Day2]世界冰球锦标赛译自 CEOI2015 Day2 T1「Ice Hockey World Championship」 今年的世界冰球锦标赛在捷克举行.Bobek ...

  4. Contrastive Loss (对比损失)

    参考链接:https://blog.csdn.net/yanqianglifei/article/details/82885477 https://blog.csdn.net/qq_37053885/ ...

  5. Xgboost理解

    一.xgboost模型函数形式 xgboost也是GBDT的一种,只不过GBDT在函数空间进行搜索最优F的时候,采用的是梯度下降法也就是一阶泰勒展开:而xgboost采用的是二阶泰勒展开也就是牛顿法, ...

  6. elasticsearch常见异常及解决办法

    报错信息:Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 20602552 ...

  7. ajax请求成功但不执行success-function回调函数的问题

    在success:function(data){}下面加个error:function(){},看看是不是出错了走了error.如果是,说明返回值类型不符合要求. 比如:下面代码返回String类型. ...

  8. (maven项目)使用java -jar命令遇到的小问题|xx.jar中没有主清单或Error:Invalid or corrupt jarfile xx.jar

    xx.jar中没有主清单或Error:Invalid or corrupt jarfile xx.jar 遇到这个问题,是因为你的jar包没有设置主类的入口. 即在META-INF文件夹的MANIFE ...

  9. 【前端vue开发】vue开发总结

  10. Java abstract 关键字

    abstract是声明抽象类和抽象方法的关键字 包含抽象方法的类叫抽象类,如果一个类中包含一个或多个抽象方法,该类必须被限定为抽象的,否则编译器会报错,抽象类不可创建对象,创建抽象类的对象编译器会报错 ...