I wrote a question below : String parse to Date yyyymmdd
But now I'm facing a new similar question :
What if I want to parse a string yymmdd to a date?
for example :
190503 instead of 20190503.
When I do the following :
String dateToConvert = '190503';
Date mydate = Date.newInstance(Integer.valueOf(dateToConvert.left(2)), Integer.valueOf(dateToConvert.mid(2,2)), Integer.valueOf(dateToConvert.right(2)));
I get 0019-05-03.
I get the date value from a webservice - and I can replace the first two zeros with '20', and it will be work for a long time, but there is another way to do it and not hardcoded?
Thanks in advance!