parse Date in long value to string - Android java.util

Android examples for java.util:Date Parse

Description

parse Date in long value to string

Demo Code

import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class Main{
    public static SimpleDateFormat formatDate = new SimpleDateFormat(
            "yyyy-MM-dd", Locale.getDefault());

    public static String parseDate(long timeInMillis) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timeInMillis);
        Date date = calendar.getTime();
        return formatDate(date);
    }//from   w w  w.  j av  a  2  s  .c o m

}

Related Tutorials