+ Start a Discussion
bca321bca321 

subString

Message Edited by bca321 on 03-12-2009 10:07 AM
Venkat PolisettVenkat Polisett

bca321 wrote:
Hi I want to know how to write down substring for date.

 

my date format is 09 JAN 12

 

 String year = '09';

year = pDueDate.subString(0,2);

For year subString is (0,2)


String year = '09';

year = pDueDate.subString(0,2);
String month = 'Jan';

month = pDueDate.subString();
String day = '10';

day = pDueDate.subString();
String hour = '00';

hour = pDueDate.subString();
String minute = '00';

minute = pDueDate.subString();
String second = '00';

second = pDueDate.subString();
 

How to write down subString  for month, day, houre, minute and second.
substring --->   

Returns a new String that begins with the character at

the specified startIndex and extends to the character

at endIndex - 1.

 

String pDueDate = '09 JAN 12';

 

String year = pDueDate.subString(0,2);

System.debug('Year = ' + year);

 

String month = pDueDate.subString(3,6);

System.debug('Month = ' + month);

 

String day = pDueDate.subString(7);

System.debug('Day = ' + day);