I have 3strings. I want to convert it into date
How to achieve this ?
string a='20';
string b='4';
string c='1993';
String dt = DateTime.newInstance(a,b,c).format('d-MM-YYYY');
I have 3strings. I want to convert it into date
How to achieve this ?
string a='20';
string b='4';
string c='1993';
String dt = DateTime.newInstance(a,b,c).format('d-MM-YYYY');
Best Answer
Alternatively, the way you were headed it's something like this:
String dt = Date.newInstance(Integer.valueOf(c),Integer.valueOf(b),Integer.valueOf(a)).format();
Keep in mind:
newInstance
method takes Integers as parametersformat()
will format the date in the current user's localeRead more on Date Methods