AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Apex convert string to integer2/21/2024 ![]() Get to know more about Salesforce Data Type from our blog- Salesforce Data Types and Field Types ! valueOf(toConvert) - This method returns a string that represents the given object argument. ![]() valueOf(longToConvert) - This method returns the string that has the value of given Long.String sInteger = String.valueOf(myInteger) valueOf(integerToConvert) - This method returns the string that has the value of the given Integer.valueOf(doubleToConvert) - This method returns the given Double.valueOf(decimalToConvert) - This method returns the string that has the value of the given Decimal.valueOf(datetimeToConvert) - This method returns a date specified in the string in the format of “yyyy-mm-dd hh:mm:ss” according to the local time zone.ĭateTime dt = datetime.newInstance(1995, 2, 25).valueOf(dateToConvert) - This method returns a date specified in the string in the format of “yyyy-mm-dd”.There are various versions of this string method: Integer result = myString1.indexOf(mystring2, 1) indexOf(substring, index) - This string method returns the index of when the first time the substring occurred from the given index.Integer result = myString1.indexOf(mystring2) indexOf(substring) - This string method returns the index of when the first time the substring occurred.Compare two equal ID values of different lengths: Compare a string to an ID of the same length. Compare a string to an object containing a number Compare a string to an object containing a string System.assert(s.endsWith('World')) equalsĮquals(stringOrld) is used when you want to compare an object that is a string or an ID, to a given string. System.assertEquals(s2, s1.deleteWhitespace()) ĭifference(secondString) returns the difference between the first and the second string.ĮndsWith(suffix) compares the given string with a specified suffix and returns true only if the string ends with the suffix. System.assertEquals(1, s.countMatches('Hey')) deleteWhitespaceĭeleteWhitespace() removes the whitespaces from the string. System.assertEquals(2, s.countMatches('Hey')) System.assertEquals(1, s.countMatches('Hey')) ![]() System.assertEquals(result, true) countMatchesĬountMatches(substring) returns the value as the number of times that the substring appears in the string that is called the method. System.assertEquals(72, str.codePointAt(0)) ĬompareTo(secondString) compares two strings in the dictionary order based on their Unicode values.Ĭontains(substring) returns true if the string that called this method contains the characters in the same sequence as the substring specified. System.assertEquals(937, str.charAt(0)) codePointAtĬodePointAt returns the value of the Unicode at the given index. If the given size is smaller than the string then the string is returned as it is without the padding string.ĬharAt(index) string method returns the value of the character at the index given.įor example: String str = 'Hello Intellipaat.'
0 Comments
Read More
Leave a Reply. |