Pass Date string in dd/MM/yyyy format - Java java.util

Java examples for java.util:Date Format

Description

Pass Date string in dd/MM/yyyy format

Demo Code


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

import java.util.Date;

public class Main {


    public static Date getDate(String date) {

        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        Date result = null;/*from  w  w  w .  j  a v a  2s . co  m*/

        try {
            result = formatter.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return result;
    }
}

Related Tutorials