These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Date Format Conversion

Fridgie
Registered: Mar 24 2009
Posts: 26

I have set up a text box in a form designed in Livecycle for the purpose of a date being entered. I have successfully worked out how to check whether the date format fits the exact format I require using java. What I haven't been able to successfully do is convert a date format I don't want entered into the date format I do want entered. (Please note I'm using a text box because I've had a number of problems getting the date picker to work successfully, particularly with clients in other countries).

As such, can anyone please advise me what java code I need to convert one date format into another ie
MM/DD/YYYY to be converted to DD/MM/YYYY or
MM/DD/YYYY to be converted to DD-MMM-YYYY

Thank you for your time.

Fridgie
Registered: Mar 24 2009
Posts: 26
I had thought that something like this might work but I think I'm missing something:

var oldDate = this.rawValue;
var nDate = util.scand("dd/mm/yyyy",oldDate);
this.rawValue = util.printd("dd-mmm-yyyy", nDate)

Any help would be appreciated. Thanks
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Use this FormCalc-Script in the layout:ready event of your date field.

$.rawValue = Format("DD.MMM.YYYY", $.rawValue)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Fridgie
Registered: Mar 24 2009
Posts: 26
Thank you for your reply Radzmar.
I note that your code works if the entry is via a calendar drop down box but appears to result in a blank if the entry is typed in.

Also, would you be aware of how I can achieve this using java as I wish to incorporate it into a larger body of code? Thanks
Fridgie
Registered: Mar 24 2009
Posts: 26
I think I found the answer. For anyone who is interested the following code used as part of a normal text box under validation will convert a date entered in the format of DD/MM/YYYY to DD-MMM-YYYY. I hope this helps someone.

var origDate = this.rawValue;
var newDate = util.scand("dd/mm/yyyy",origDate);
var convDate = util.printd("dd-mmm-yyyy", newDate)

if (this.rawValue == null);

else
{this.rawValue = convDate};