E9.2 Date Formats in Orchestrations and Service Requests

eydeak

Reputable Poster
Hi,

I wanted to get some feedback on how people are dealing with different date formats inside orchestrations and service requests. Here is a simple example:
I have form service request 1 which runs an application to return a date value. This service request is returning an empty date as the word NULL and a populated date in format YYYY-MM-DD.
I have a second form service request running another application to update a date value. The form will validate the date entered based on user profile date format, which varies for users in different countries. Example USA users are MM/DD/YYYY and China users are DD/MM/YYYY.
I have an orchestration where I pass in some values and then execute form request 1 to find the date, then execute form request 2 to update the date somewhere else.
If I simply map the date returned from form request 1 into the date in form request 2, it will always fail as an invalid date due to the formatting of the date.

The only thing I've come up with to handle this is to use custom service requests to get the user profile and groovy script to convert the date to user profile format. Then I can pass the properly formatted result into form request 2.

I was wondering if anyone else out there has other tips or tricks for dealing with this kind of situation. Perhaps something easier that I've been over looking. Someplace maybe where I can tell the form requests to return dates in user profile format?

Thanks,
Ellen
 

Adam (DF)

Active Member
I would expect that passing dates around would be more reliable than passing date formatted strings around. I would take in a date, if possible, but if not, the first thing would be to parse the string into a date, so I could pass that around.
 

johnd

Active Member
USA users need to get a grip and ditch their massively confusing M D Y stuff lol

the form will validate the date entered based on user profile date format, which varies for users in different countries. Example USA users are MM/DD/YYYY and China users are DD/MM/YYYY.
Would BSFN GetUserDateSeperatorAndFormat B0001390 help you then?
Get their mask then use ConvertStringDateToDateFormat B0800208 to convert the text format.
I just coded this this week so it's fresh in my head :)
 

jlocicero

Member
We created a custom groovy request to do this (Yesterday in this example):

import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

def Yesterday = new Date() - 1
def sdf = new java.text.SimpleDateFormat("yyyy-MM-dd")
def YesterdayYMD = sdf.format(Yesterday)
def sdf2 = new java.text.SimpleDateFormat("MM/dd/yyyy")
def YesterdayMDY = sdf2.format(Yesterday)
returnMap.put("Yesterday", Yesterday);
returnMap.put("YesterdayYMD", YesterdayYMD);
returnMap.put("YesterdayMDY", YesterdayMDY);
return returnMap;
}

The date is then available in either format as an input for the other requests in the Orchestration.
 
Top