EncoderUtils { public static String encodeDateTime(Date date) { final FastDateFormat format = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss Z", TimeZone.getTimeZone("GMT"), Locale.US); return format.format(date); }  static String encodeDateTime(Date date);  }
@Test public void testSimpleEncodeDateTime() { assertThat(EncoderUtils .encodeDateTime(new Date(1094188123661L))).isEqualTo("03-Sep-2004 05:08:43 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(1134188123661L))).isEqualTo("10-Dec-2005 04:15:23 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(1184188123661L))).isEqualTo("11-Jul-2007 21:08:43 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(1194188123661L))).isEqualTo("04-Nov-2007 14:55:23 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(12107305944309L))).isEqualTo("31-Aug-2353 20:32:24 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(11108230972614L))).isEqualTo("03-Jan-2322 11:42:52 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(11102649584790L))).isEqualTo("30-Oct-2321 21:19:44 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(11100000174728L))).isEqualTo("30-Sep-2321 05:22:54 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(12100005497072L))).isEqualTo("08-Jun-2353 08:38:17 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(12100497095056L))).isEqualTo("14-Jun-2353 01:11:35 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(12103063589157L))).isEqualTo("13-Jul-2353 18:06:29 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(10101292334681L))).isEqualTo("05-Feb-2290 02:32:14 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(11101731873573L))).isEqualTo("20-Oct-2321 06:24:33 +0000"); assertThat(EncoderUtils .encodeDateTime(new Date(10100859169426L))).isEqualTo("31-Jan-2290 02:12:49 +0000"); }