Write code to convert Date value in long to String
return a string in format yyyy/MM/dd
Use SimpleDateFormat
//package com.book2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) { long time = 42; System.out.println(DateStr(time)); }// w w w . ja va 2 s . c om public static String DateStr(long time) { SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd"); Date date = new Date(time * 1000); String timeStr = format.format(date); return timeStr; } }