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. javascript的this分别代表什么

    鉴于大家对this到底代表的是什么有疑问,现在将我个人理解的this的情况整理如下.有错误请指正. 第一种情况:  如果是一个全局的function,则this相当于window对象. 这个打印出来的 ...

  2. TensorFlow 从零到helloWorld

    目录 1.git安装与使用 1.1 git安装 1.2 修改git bash默认路径 1.3 git常用操作 2.环境搭建   2.1 tensorflow安装   2.2 CUDA安装   2.3 ...

  3. 015_sublime插件管理及所有非常有用插件

    一. <1>按照这个进行Package Control的安装 https://packagecontrol.io/installation import urllib.request,os ...

  4. Gentoo rc-update service ‘net.eth0′ does not exist

    最近迷上了Gentoo,并相信以后也会把更多的精力放在Gentoo上,不过Gentoo的安装的过程的确让很多人却步. 本文只提到添加net.eth0到默认的运行级别时一个很小的报错解决. # nano ...

  5. 使用eclipse为Servlet在Tomcat中的部署方法

    一:下载安装jdk,tomcat,eclipse: 使用eclipse建立动态web项目lcj,更改编译文件目录,方法如下: 右键点击→工程名称→属性(Properties)或(Building Pa ...

  6. Linux配置Selenium+Chrome+Java实现自动化测试

    1.安装chrome sudo apt-get install libxss1 libappindicator1 libindicator7 wget https://dl.google.com/li ...

  7. K-means聚类算法的三种改进(K-means++,ISODATA,Kernel K-means)介绍与对比

      一.概述 在本篇文章中将对四种聚类算法(K-means,K-means++,ISODATA和Kernel K-means)进行详细介绍,并利用数据集来真实地反映这四种算法之间的区别. 首先需要明确 ...

  8. YOLOv2训练自己的数据集(VOC格式)

    下周试试,参考:http://blog.csdn.net/ch_liu23/article/details/53558549 http://blog.csdn.net/sinat_30071459/a ...

  9. ruby语言学习笔记2

    ruby学习笔记2  (摘自<ruby程序设计语言教程(中文版)>.pdf,全书25页) 1.同一个问题ruby有多个解决方案,途径 ruby之父:松本行弘(Matz),1993年创立 r ...

  10. **CI中自动类加载的用法总结

    总结: 哪一个类中用到某一个类,就在构造函数中加载这个类,比如m_attach,C_Feed类中有用到,那么就在构造函数中加载 控制器: class C_Feed extends CI_Control ...