Ad (728x90)

Filled Under:

Convert String to Date format in Java

java
Java Code for Converting String to Date format:



import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 *
 * @author www.tekhnologia.com
 */

public class ConverterClass {
   
    public void stringToDate(int date, int month, int year) {
       
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

        String strDate = date + "/" + month + "/" + year;
        try {
           
            Date dateForm = dateFormat.parse(strDate);
            System.out.println("New Date = " + dateFormat.format(dateForm));
           
        } catch (ParseException e) {
            e.printStackTrace();
        }
       
    }

   public static void main(String[] args) {
        new ConverterClass().stringToDate(29, 11, 1982);
    }
}

Out put will be : New Date = 29/11/1982

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

Please write to us here...

 

We are featured contributor on entrepreneurship for many trusted business sites:

  • Copyright © Tekhnologia™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.