Java Long Number to Date format(long dateInMillis, String pattern)

Here you can find the source of format(long dateInMillis, String pattern)

Description

format

License

Open Source License

Declaration

public static String format(long dateInMillis, String pattern) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oobium, Inc./*from ww w .  ja v  a 2s  .c  o  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation
 ******************************************************************************/

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String format(Date date, String pattern) {
        if (date == null) {
            return "";
        }
        return new SimpleDateFormat(pattern).format(date);
    }

    public static String format(long dateInMillis, String pattern) {
        return new SimpleDateFormat(pattern).format(new Date(dateInMillis));
    }
}

Related

  1. dateToString(long date, String formate)
  2. dateToStrLong(java.util.Date dateDate, String format)
  3. format(long date)
  4. format(Long date, String pattern)
  5. format(long date, String pattern)
  6. format(Long dateMs, String type)
  7. format(Long dateTmie, String formate)
  8. format(long time, SimpleDateFormat format)
  9. formatDate(final long date)