Apache Commons Lang 3.0 is a java library with lot of utilities and reusable components. This requires the library commons-lang3-3.0.1.jar to be in classpath. The following example shows formatting date using FastDateFormat .
package com.bethecoder.tutorials.commons_lang.tests.gen; import java.util.Date; import org.apache.commons.lang3.time.DateFormatUtils; public class FastDateFormatTest { /** * @param args */ public static void main(String[] args) { System.out.println(DateFormatUtils.format(new Date(), DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern())); System.out.println(DateFormatUtils.format(new Date(), DateFormatUtils.ISO_DATE_FORMAT.getPattern())); System.out.println(DateFormatUtils.format(new Date(), DateFormatUtils.ISO_TIME_NO_T_TIME_ZONE_FORMAT.getPattern())); } }
Tue, 08 Nov 2011 00:05:35 +0530 2011-11-08 00:05:35+05:30