Archive for February, 2012

The Date Formatter date/time patterns

February 10, 2012

Some Background

Pipes V1 was written in Perl, and Pipes V2 is written in Java. The two languages have their different ways of doing things, and those aren’t always going to be compatible.

The Original Patterns

These are the ones the Pipes documentation still points to:

Most of those still work. So we can use %a to obtain an abbreviated representation of the day, Mon to Sun, and %A to obtain a full representation, Monday to Sunday. The Pipes team have worked to ensure that as many of the parameters as possible still work. Unfortunately some parameters, such as %P for lower-case am/pm no longer work: Java has no equivalent format. %p can still be used to obtain an upper-case AM/PM.

The Java Patterns

Although it’s not mentioned in the documentation, standard Java patterns can also be used. Those can be found at:

Java takes a different approach to Perl in the way it allows for different formats. For instance, the pattern letter of a day is E. EEE or shorter will return, for instance, Mon. EEEE or longer will return Monday. The pattern letter for the month is M. For February M returns 2, MM returns 02, MMM returns Feb and MMMM or longer returns February.

Both the original, Perl, patterns and the Java patterns are supported, but I wouldn’t try mixing bits of Perl with bits of Java.