Convert date in long to String by format - Android java.util

Android examples for java.util:Date Convert

Description

Convert date in long to String by format

Demo Code

import android.annotation.SuppressLint;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main{

    public static String date2String(long time, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(time);
    }// w ww.  ja v  a 2  s.  c  o m

}

Related Tutorials