Java Milliseconds dateToMillis(Date date)

Here you can find the source of dateToMillis(Date date)

Description

Formats a Date as a fifteen character long String made up of the Date's padded millisecond value.

License

Open Source License

Declaration

public static final String dateToMillis(Date date) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    private static final char[] zeroArray = "0000000000".toCharArray();

    /**// w w  w  . j  ava  2 s .  co m
     * Formats a Date as a fifteen character long String made up of the Date's
     * padded millisecond value.
     */
    public static final String dateToMillis(Date date) {
        return zeroPadString(Long.toString(date.getTime()), 15);
    }

    public static final String zeroPadString(String string, int length) {
        if (string == null || string.length() > length) {
            return string;
        }
        StringBuilder buf = new StringBuilder(length);
        buf.append(zeroArray, 0, length - string.length()).append(string);
        return buf.toString();
    }
}

Related

  1. CreateDate(long milliseconds)
  2. createFromMillis(long milliseconds)
  3. csvAnnotatedMilliString(long totaltime)
  4. cutoffTimeMillis(long time)
  5. cyclesToMillis(long cycles, double hz)
  6. dateToMillis(Date date)
  7. dateToMillis(long now)
  8. dayValue2Millisecond(int dayValue)
  9. decomposeMillis(long millis)