Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Date format

Avatar

Level 2

Hi

I've added a date/time field and specified system locale in the field tab.

If I then  save and open in acrobat, select the arrow the popup calendar shows the date in Uk format (my system)  the box also shows the dat in UK format however when I click on the date in the popup calendar to select the date in the form box it changes to US format.

Has anyone any idea why?

thanks

Ian

4 Replies

Avatar

Former Community Member

Hi Ian,

Take a look at the validation pattern of this date field.

Maybe the "display" pattern is set to US format thus it changes once the you finish edit the value.

Yan.

Avatar

Level 2

Hi

great thought tried setting to various alternatives but the date still comes out as yyyy\mm\dd

weird

cheers

Ian

Avatar

Level 2

Try using this function.

/**

* Rewrite date string function (in format DD-MM-YYYY) ; will return (modified) string

* Leading zeros will be added in day and month: 1-3-1921 will become 01-03-1921

*

* @param string

* @return string

*/

function

date ( sDate )

{

           if( typeof(sDate) == "string" )

           {

                     var aDate = RegExp("^(\\d{1,2})[-\/.](\\d{1,2})[-\/.](\\d+)").exec(sDate);

                     if( aDate != null)

                     {

                         aDate[1]

= String(100 + Number(aDate[1])).substring(1);

                         aDate[2] = String(100 + Number(aDate[2])).substring(1);

                         aDate[3]

= ( aDate[3] < 50 ) ? parseInt(aDate[3],10) + 2000 : aDate[3];

                         aDate[3]

= ( aDate[3] < 100 ) ? parseInt(aDate[3],10) + 1900 : aDate[3];

                         sDate

= aDate[1] + "-" + aDate[2] + "-" + aDate[3];

                     }

           }

return sDate;

}

Then in the exit-event of the date-field:

this.formattedValue

= date(this.formattedValue);

Avatar

Level 2

Hi

thanks for that, things went from bad to worse to I started from scratch and on a new form the date format was picked up correctly.

Thanks

Ian