You need to sign in to do that
Don't have an account?
Heather Mickey
How to read/convert text string into day and time
There is a field that currently stores Office Times in the following format, based on the input from a Custom S-Control.
Field Name: Office Times
Data Stored (example): &m=60,1320&tu=105,1370&w=73,1343&th=75,1365&f=150,1260&sa=480,1020
I'd like to create a new field which takes this data stored and makes it more user reading friendly.
M: 01:00-22:00
Tu: 01:45-22:50
W: 01:13-22:23
Th: 01:15-22:45
F: 02:30-21:00
Sa: 08:00-17:00
**The number stored in the long text field from the custom s-control is in minutes. So it needs to get converted into military (24h) time.
I'm having a difficult time figuring out how to do this as I am still very new to Apex. I tried addressing this via a workflow and formulas but I haven't had any luck.
*There is one other tricky part to this. Someone could enter "&tu=360,615;780,1020", meaning
Tu: 06:00-10:15, 13:00-17:00
Thank you so much,
Heather
Field Name: Office Times
Data Stored (example): &m=60,1320&tu=105,1370&w=73,1343&th=75,1365&f=150,1260&sa=480,1020
I'd like to create a new field which takes this data stored and makes it more user reading friendly.
M: 01:00-22:00
Tu: 01:45-22:50
W: 01:13-22:23
Th: 01:15-22:45
F: 02:30-21:00
Sa: 08:00-17:00
**The number stored in the long text field from the custom s-control is in minutes. So it needs to get converted into military (24h) time.
I'm having a difficult time figuring out how to do this as I am still very new to Apex. I tried addressing this via a workflow and formulas but I haven't had any luck.
*There is one other tricky part to this. Someone could enter "&tu=360,615;780,1020", meaning
Tu: 06:00-10:15, 13:00-17:00
Thank you so much,
Heather
You will need to build a parser to parse the string:
You can use string utils (left,right, mid, lastindexof, etc.)
http://apex-commons.github.io/api/stringutils/
to build your logic.
Key characters to focus on: &m=60,1320&tu=105,1370&w=73,1343&th=75,1365&f=150,1260&sa=480,1020
& = , ;
Since there are multiple variations, you need to test all scenarios.
Thx