Skip to content

Dave Helgerson

Software Design, Development, and Administration

  • Home
  • Contact
  • Resume

Convert a number to a string left padded with 0s in Apex

5 Nov
Posted on November 5, 2017November 5, 2017Author daveh
Integer MyInt = 54;
String MyString = String.valueOf(MyInt).leftPad(5, '0');

system.assertEquals('00054', MyString);

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Apex, Salesforce

Post navigation

« Find Process Builder Name by Id
Salesforce Dashboard Rotation and Refresh with Tampermonkey »
Super Clone Pro

Recent Posts

  • Add Days to a Salesforce Formula DateTime Field and Adjust for Daylight Savings Time
  • Salesforce Date Formula for Finding the Next Business Day that Skips Holidays
  • Get Record Type ID by Name for a Salesforce Object
  • Salesforce Dashboard Rotation and Refresh with Tampermonkey
  • Convert a number to a string left padded with 0s in Apex
  • Find Process Builder Name by Id
  • Alert with Option Buttons in the Window Body – jQueryUI in a Salesforce Custom Button
  • Alert with Three Options – jQueryUI in a Salesforce Custom Button
  • Eclipse Force.com IDE Editor Configuration Preferences
  • Apex File Naming Standards
  • Using the Enter Keypress Event in Visualforce to Search or Change Checkbox Properties
  • Javascript Popup Window Tips for Salesforce
© 2021 Dave Helgerson
Powered by WordPress / Theme by Design Lab