If I changed the time zone in Salesforce Org then getting the 'Invalid date Error'. It works fine if I select the Indian time zone but If I select other than current Timezone then Displaying error while parsing the date.
The Code is like this:
String dayOrDate = '2015-06-04';
List <String> dateParts = dayOrDate.split('-');
Date tempDate = date.parse(dateParts[1]+'/'+dateParts[2]+'/'+dateParts[0]);
Datetime dateWithTime = datetime.newInstance(tempDate.year(), tempDate.month(),tempDate.day());
dayOrDate = dateWithTime.format('dd- MMM-yy');
Please Can anyone please point me to solution ? Thanks in Advance!!