Parse yyyy-MM-dd hh:mm:ss format String To Date - Android java.util

Android examples for java.util:Date Parse

Description

Parse yyyy-MM-dd hh:mm:ss format String To Date

Demo Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Date StringToDate(String datestring) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date date = null;/*w ww . j a  va2 s  . com*/
        try {
            date = df.parse(datestring);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related Tutorials