Format Date in long value in yyyy-MM-dd HH:mm:ss format - Java java.util

Java examples for java.util:Date Format

Introduction

The following code shows how to mill Date Format.

Demo Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static void main(String[] argv) {
        long millis = 12312312312312342L;
        millDateFormat(millis);//from ww  w  .j a v  a2s  .  c  o  m
    }

    public static void millDateFormat(long millis) {
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        Date date = new Date(millis);
        String time = format.format(date);
        System.out.println("time1:" + time);
    }
}

Related Tutorials