Format Date in long as MMM dd, yyyy format - Android java.util

Android examples for java.util:Date Format

Description

Format Date in long as MMM dd, yyyy format

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class Main{

    @SuppressLint("SimpleDateFormat")
    public static String getDate(long timeStamp) {
        try {//ww  w. j  ava2 s  . c o m
            SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy");
            Date netDate = (new Date(timeStamp));
            return sdf.format(netDate);
        } catch (Exception ex) {
            return "";
        }
    }

}

Related Tutorials