Java examples for java.util:Date Format
Format a date to String as yyyy-MM-dd'T'HH:mm:ss.SSSZ format
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { Date dat = new Date(); System.out.println(formatDate(dat)); }// w w w . j a v a2s . co m private final static SimpleDateFormat dateFmt = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); /** Format a date as text */ public static String formatDate(Date dat) { return dateFmt.format(dat); } }