Ramiro Nava Castro Ramiro Nava Castro -4 years ago 217
Android Question

Android how to set date and calendar objects from string

i have a string with a date in this format yyyyMMddHHmmss, so i want to know how to set a Date object and a Calendar object in android.

For example if my string date is 20120215102400 how i make a function that returns a Calendar object with that date, and also how i make a function that returns a Date object. Maybe is a easy one but i still learning android and java too.

Answer Source
String mytime="20120215102400";
        SimpleDateFormat dateFormat = new SimpleDateFormat(

        try {
            Date myDate = dateFormat.parse(mytime);
        } catch (ParseException e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download