Java Long Number to Date dateToString(long date)

Here you can find the source of dateToString(long date)

Description

Formats millisecond time to string.

License

Open Source License

Parameter

Parameter Description
date - the date in milliseconds.

Return

- the string representation of the date in milliseconds.

Declaration

public static String dateToString(long date) 

Method Source Code

//package com.java2s;
/*/*  w  w  w .j  a  va  2 s.  com*/
 * Icegem, Extensions library for VMWare vFabric GemFire
 * 
 * Copyright (c) 2010-2011, Grid Dynamics Consulting Services Inc. or third-party  
 * contributors as indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  
 * 
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License v3, as published by the Free Software Foundation.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * You should have received a copy of the GNU Lesser General Public License v3
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /** */
    private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

    /**
     * Formats date to string.
     * 
     * @param date
     *            - the date.
     * @return - the string representation of the Date object.
     */
    public static String dateToString(Date date) {
        return formatter.format(date);
    }

    /**
     * Formats millisecond time to string.
     * 
     * @param date
     *            - the date in milliseconds.
     * @return - the string representation of the date in milliseconds.
     */
    public static String dateToString(long date) {
        return dateToString(new Date(date));
    }
}

Related

  1. convertMsToSimpleDate(long Millis)
  2. convertUNIXTimeToString(long time)
  3. dateToAPODString(long date)
  4. dateToLong(String date)
  5. dateToPGNDate(long when)
  6. dateToString(long date)
  7. dateToString(long date)
  8. dateToString(long date)
  9. dateToString(long date, String formate)