Patterns in PDF – XFA Date Format and Java SimpleDateFormat patterns

In this article we take a look at the difference between XFA supported DateTimeField date pattern and Java SimpleDateFormat.

DateTime Field in XFA forms requires date time pattern for data input and data output. These patterns are defined in <picture> tags in field tag. Input date time format picture tag is defined as a child tag which is located inside <ui> tag, however ouput date time format picture tag is defined inside <format> tag which is a child tag of <field> (please note this is not a children of UI tag).

 As you might already know java SimpleDateFormat class uses these abbreviations …. 

 dd/MM/yyyy  =  16/06/2012

dd-MMM-yyyy  =  15-Jan-2013

EEEE, dd/MMM/yy = Monday, 21/Oct/13

However the same examples are represented in XFA as this format

DD/MM/YYYY = 16/06/2012   { Note date and year characters are in capital }

DD-MM-YYYY = 15-Jan-2013 { same as above date and year are in capital )

EEEE, DD/MMM/YY = Monday, 21/Oct/13  { same as above but no changes to day of the week }

So all you need to do is replace lower case d and y to convert into SimpleDateFormat supported String.

However XFA forms support additional strings and words to represent default date time behaviours.

XFA wording XFA Format Simple Date Format (Java)
 date.default{}  DD MMM YYYY  dd MMM yyyy
 date.short{}  DD/MM/YYYY  dd/MM/yyyy
 date.medium{}  DD MMM YYYY  dd MMM yyyy
 date.long{}  DD MMMM YYYY  dd MMMM yyyy
 date.full{}  EEEE, DD MMMM YYYY  EEEE, dd MMMM yyyy

Hopefully this information is useful if you are in the middle of converting XFA supported date time pattern to Java Supported Pattern.

Please Note: these patterns may change if you are using US locales instead of UK (for example dd/MM/yyyy should be considered as MM/dd/yyyy).

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (TwitterFacebook and Google+) or the Blog RSS.

The following two tabs change content below.

suda

Java EE developer at IDRSolutions
Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.

Related Posts:

suda

About suda

Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>