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. 玩转Hook——Android权限管理功能探讨(二)

    距离我上一篇研究ptrace的随笔http://www.cnblogs.com/zealotrouge/p/3544147.html已经过去半年了,最近不忙的时候抽空继续研究了下.同样,参考了Prad ...

  2. 【译】使用OpenVAS 9进行漏洞扫描

    本文译自Vulnerability Scanning with OpenVAS 9 part 1: Installation & Setup系列,本文将融合目前已经发表的四个部分. Part ...

  3. 使用eclipse构建Maven项目及发布一个Maven项目

    开发环境: Eclipse Jee Mars(截止2015年12月1日目前的最新版eclipse4.5),下载地址:http://www.eclipse.org/downloads/ 因为此版本已经集 ...

  4. idea如何编译maven项目

    这里我们介绍两种方式,如何调试出窗口 点击菜单栏View->Tool  Windows->Maven projects 点击菜单栏Help->Find Action(Ctrl+Shi ...

  5. html圈圈

    <html> <head> <meta charset="utf-8" /> <link href="images/style. ...

  6. C#小票打印机

    使用的佳博GP-5890XIII http://www.cnblogs.com/lovenan/p/3217448.html using System; using System.Collection ...

  7. Simple Web API Server in Golang (1)

    To be an better Gopher, get your hands dirty. Topcoder offered a serials of challenges for learning ...

  8. python3脚本获取本机公网ip

    python脚本获取本机公网ip   1.获取公网IP地址方式,访问:http://txt.go.sohu.com/ip/soip 2.代码实现 import requests import re r ...

  9. css3中的伪类选择器

    一.动态伪类 动态伪类,因为这些伪类并不存在于HTML中,而只有当用户和网站交互的时候才能体现出来,动态伪类包含两种,第一种是我们在链接中常看到的锚点伪类,如":link",&qu ...

  10. 关于我学XSS躺过的那些坑

    XSS字符编码 在学习编码绕过时由于数量多,类型相似,不太容易记得住,记得全,故做此记录. 0x01 Html标签属性中执行 简单了解: Html标签属性中的XSS问题多属于javascript伪协议 ...