Android examples for java.util:Date Format
Format long value to date in yyyy-M-d format
import java.text.SimpleDateFormat; public class Main{ private static String toNYR(long data) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-d"); try {//w ww. j a v a 2s . c o m return dateFormat.format(data); } catch (Exception e) { return ""; } } }