suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Patterns in PDF – XFA Date Format and Java SimpleDateFormat patterns

1 min read

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 wordingXFA FormatSimple 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).



Are you a Developer working with PDF files?

Our developers guide contains a large number of technical posts to help you understand the PDF file Format.

Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.