Parse Date to String by format - Android java.util

Android examples for java.util:Date Parse


Parse Date to String by format

Demo Code

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

public class Main{

    public static Date getDateByString(String dateString, String format) {
        Date date = null;/*from   ww  w. j ava  2  s  . c om*/
        try {
            date = new SimpleDateFormat(format).parse(dateString);
        } catch (ParseException e) {
        return date;


Related Tutorials