Apex Method of the Day – String myString.repeat(numTimes)

public class TestUtility
{
   static Integer s_num = 1;

   public static String getFakeId(Schema.SObjectType sot)
   {
      String result = String.valueOf(s_num++);
      return sot.getDescribe().getKeyPrefix() + 
         '0'.repeat(12-result.length()) + result;
   }
}

Force.com Apex Code Developer’s Guide – String Methods

This entry was posted in Documentation and tagged , . Bookmark the permalink.

One Response to Apex Method of the Day – String myString.repeat(numTimes)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s