You need to sign in to do that
Don't have an account?
Manoj Reddi
When Uploading Files using Visualforce page How to convert a text field values to a date field
Hi
I have the following text field value in excel file:
20170320
I would like to convert it to a date field value when uploading files using Apex class & Visualforce Page:
03/20/2017
Thanks
I have the following text field value in excel file:
20170320
I would like to convert it to a date field value when uploading files using Apex class & Visualforce Page:
03/20/2017
Thanks
There is no direct function to do that.
You can do something like this.:
Let me know if it helps
Thanks!
All Answers
In the controller, you can use text functions to split the text into the year, month and day and use the date function to convert the text to the date value. If you would like to know more, follow the links below
Date functions: link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm).
Sting functions: link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm)
Hope it helps
RD
There is no direct function to do that.
You can do something like this.:
Let me know if it helps
Thanks!
Thanks for Reply,
You write only one text, but i need multiple texts to date, see below one
20180228
20180228
20180228
20180228
20180228
20180228
20180116
20180228
20180228
Thanks
Manoj
Put all these values in a list of string type and then start a for loop to traverse that list and write date extraction logic inside that for loop and add the final dates to a new list of string type.
Thanks
Please mark the best answer if I was able to help you.
Thanks!