Java examples for java.util:Date Format
get yyyy/MM/dd Format Time
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static void main(String[] argv) throws Exception { long time = 2; System.out.println(getYMDFormatTime(time)); }/* www . ja va2 s . c o m*/ public static String getYMDFormatTime(long time) { return getFormatTime("yyyy/MM/dd", time); } public static String getFormatTime(String formatter, long time) { SimpleDateFormat format = new SimpleDateFormat(formatter, Locale.getDefault()); return format.format(new Date(time)); } }