Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getMsgDate(long msg_time) { Calendar cl = Calendar.getInstance(); cl.setTimeInMillis(msg_time); //here your time in miliseconds String date = ""; String[] monthNames = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SimpleDateFormat month_date = new SimpleDateFormat("MMM"); String month_name = monthNames[cl.get(Calendar.MONTH)]; int day = cl.get(Calendar.DAY_OF_MONTH); int year = cl.get(Calendar.YEAR); int current_year = Calendar.getInstance().get(Calendar.YEAR); if (current_year == year) { date = month_name + " " + day; } else { date = month_name + " " + day + ", " + year; } return date; } }