Utils { public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); }  static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, int offset); static void uint32ToByteArrayLE(long val, byte[] out, int offset); static void uint64ToByteArrayLE(long val, byte[] out, int offset); static void uint16ToByteStreamLE(int val, OutputStream stream); static void uint32ToByteStreamLE(long val, OutputStream stream); static void int64ToByteStreamLE(long val, OutputStream stream); static void uint64ToByteStreamLE(BigInteger val, OutputStream stream); static void stringToByteStream(String string, OutputStream stream); static void bytesToByteStream(byte [] string, OutputStream stream); static boolean isLessThanUnsigned(long n1, long n2); static boolean isLessThanOrEqualToUnsigned(long n1, long n2); static byte[] reverseBytes(byte[] bytes); static byte[] reverseDwordBytes(byte[] bytes, int trimLength); static int readUint16(byte[] bytes, int offset); static long readUint32(byte[] bytes, int offset); static long readInt64(byte[] bytes, int offset); static long readUint32BE(byte[] bytes, int offset); static int readUint16BE(byte[] bytes, int offset); static byte[] sha256hash160(byte[] input); static BigInteger decodeMPI(byte[] mpi, boolean hasLength); static byte[] encodeMPI(BigInteger value, boolean includeLength); static BigInteger decodeCompactBits(long compact); static long encodeCompactBits(BigInteger value); static long encodeCompactBits(BigInteger value, boolean negative); static Date rollMockClock(int seconds); static Date rollMockClockMillis(long millis); static void setMockClock(); static void setMockClock(long mockClockSeconds); static Date now(); static long currentTimeMillis(); static long currentTimeSeconds(); static String dateTimeFormat(Date dateTime); static String dateTimeFormat(long dateTime); static String join(Iterable<T> items); static byte[] copyOf(byte[] in, int length); static byte[] appendByte(byte[] bytes, byte b); static String toString(byte[] bytes, String charsetName); static byte[] toBytes(CharSequence str, String charsetName); static byte[] parseAsHexOrBase58(String data); static boolean isWindows(); static byte[] formatMessageForSigning(String message); static byte[] formatMessageForSigning(byte[] message); static boolean checkBitLE(byte[] data, int index); static void setBitLE(byte[] data, int index); static void sleep(long millis); static void setMockSleep(boolean isEnable); static void passMockSleep(); static void finishMockSleep(); static boolean isAndroidRuntime(); static int maxOfMostFreq(int... items); static int maxOfMostFreq(List<Integer> items); static String getResourceAsString(URL url); static InputStream closeUnchecked(InputStream stream); static OutputStream closeUnchecked(OutputStream stream); static String sanitizeString(String str, int rule); static String sanitizeString(String str); static long getTotalCoinEstimate(int nHeight); static ArrayList<String> split(String words, String regex); static int findFirstNotOf(String str, String match, int start); static org.bitcoinj.utils.Pair<Integer, String> splitHostPort(String in); static final String BITCOIN_SIGNED_MESSAGE_HEADER; static final byte[] BITCOIN_SIGNED_MESSAGE_HEADER_BYTES; static final BaseEncoding HEX; static volatile Date mockTime; }
@Test public void dateTimeFormat() { assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(1416135273781L)); assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(new Date(1416135273781L))); }