Write code to get Date By Time Stamp long value in yyyy-MM-dd hh:mm:ss format
//package com.book2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) { long timestamp = 41231232; System.out.println(getDateByTimeStamp(timestamp)); }//www .j a v a 2 s . c om public static String getDateByTimeStamp(long timestamp) { if (timestamp != 0) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); String date = sdf.format(new Date(timestamp)); System.out.println(date); return date; } else { return ""; } } public static String getDateByTimeStamp(long timestamp, String format) { if (timestamp != 0) { SimpleDateFormat sdf = new SimpleDateFormat(format); String date = sdf.format(new Date(timestamp)); return date; } else { return ""; } } }