Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Convert String to Date in Java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 278
    Comment on it

    Its very easy in java to convert String to Date. Java provides SimpleDateFormat to handle Date related functionality.
    Here we call parse() method of SimpleDateFormat.


    Example

    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class ChangeStringDate {
    public static void main(String[] args)throws Exception {
    String stringDate="17/10/2015";
    Date dateForm=new SimpleDateFormat("dd/MM/yyyy").parse(stringDate);
    System.out.println(stringDate+"\t"+dateForm);
    }
    }
    Output:

    17/10/2015 Sat Oct 31 00:00:00 IST 2015

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: