Forum Discussion
JHunt
7 years agoCommunity Hero
String s = '20170210141809'
Date myDate = Date.parse('yyyyMMddHHmmss', s)
assert myDate.format('yyyy-MM-dd HH:mm:') == '2017-02-10 14:18:'
- N78A7 years agoContributorHi, Thanks for your response. I tried the method you suggested, but it gives me error : "unparseable date"
- JHunt7 years agoCommunity Hero
My script didn't work?
I presumed you made a typo when you said that you fetched the timestamp in this format:
TRANSACTION_TIMESTAMP>20170210141809</TRANSACTION_TIMESTAMP
So I was working on the basis of just starting from:
20170210141809
If you had to start from the top one, you could just do this to get to the second one:
String s = 'TRANSACTION_TIMESTAMP>20170210141809</TRANSACTION_TIMESTAMP' Date myDate = Date.parse('yyyyMMddHHmmss', s[22..35]) assert myDate.format('yyyy-MM-dd HH:mm:') == '2017-02-10 14:18:'
That would get it working, but in that case perhaps it would be better to work on the way you are getting hold of the dates? Perhaps you could post that part of your code.
- N78A7 years agoContributor
Hi,
Thanks again.
Sorry I couldnt try again the solution suggested. Will check and come back.
Related Content
- 11 months ago
Recent Discussions
- 13 hours ago
- 2 days ago
- 3 days ago
- 3 days ago