parse string in yyyy/MM/dd format and default locale To Date - Android java.util

Android examples for java.util:Date Parse

Description

parse string in yyyy/MM/dd format and default locale To Date

Demo Code

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Base64;
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 Date parseToDate(String dateString) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd",
                Locale.getDefault());
        try {//from   www.  j av  a2s.  co  m
            return format.parse(dateString);
        } catch (ParseException e) {
            return new Date();
        }
    }

}

Related Tutorials