Here you can find the source of formatDate(long date)
public static String formatDate(long date)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014,2015 Hideki Yatomi * 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 ******************************************************************************/ import java.time.*; import java.time.format.*; import java.util.*; public class Main { private static DateTimeFormatter dateTimeFormatter; public static String formatDate(long date) { if (dateTimeFormatter == null) dateTimeFormatter = DateTimeFormatter .ofPattern("yyyy/MM/dd HH:mm:ss"); return LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault()).format(dateTimeFormatter); }//w w w. ja va 2 s .com }