How to convert String into java.util.Date

Ads
 

How to convert String into java.util.Date

Hi,

How I can convert String date into java.util.Date in a Java program?

Thanks

View Answers

July 21, 2017 at 7:13 AM

Hi,

Following is the example of converting String date into java.util.Date:

package net.roseindia;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/*
 * Format String date to date
 * format
 */
public class StringToDateExample {
    public static void main(String[] args) {
        try {
            String dtStr = "10-Feb-2017";
            DateFormat formatter;
            Date date;
            formatter = new SimpleDateFormat("dd-MMM-yyyy");
            date = (Date) formatter.parse(dtStr);
            System.out.println("Date is " + date);
        } catch (ParseException e) {
            System.out.println("Exception :" + e);
        }

    }
}

Following are best example of Java Date at roseindia.net:

Thanks

Ads









Related Tutorials/Questions & Answers:
How to convert String into java.util.Date
How to convert String into java.util.Date  Hi, How I can convert String date into java.util.Date in a Java program? Thanks   Hi... Getting time in Milliseconds Convert Date To Calendar How to convert String Date
How to convert into to String in Java?
How to convert into to String in Java?  Hi, How to convert into to String in Java? Thanks
Advertisements
How to convert a String to an int?
How to convert a String to an int?  I my program I am taking... format. Now I want to convert into int value. Tell me How to convert a String... contains the value 1025, then you can use the following code to convert the String
How to Convert String to Date?
How to Convert String to Date?  Hi, I am new in Java and learning... have to convert it to Date object. Tell me How to Convert String to Date? Thanks   Hi Dude, Its very easy to convert the String into date format
How to convert date to string in Java?
How to convert date to string in Java?  Hello developers, I have java.util.Date object and it has to be converted to date format. How to convert date to string in Java? Thanks   Hi, To convert java.util.Date object
Converting ISO8601-compliant String to java.util.Date
Converting ISO8601-compliant String to java.util.Date  Converting ISO8601-compliant String to java.util.Date
How to convert string to byte in Java
How to convert string to byte in Java  How to convert string to byte in Java
how to convert string to image in java
how to convert string to image in java  how to convert string to image in java? I know we need to convert image to a byte array at some point in my application but do not know how to convert a image into byte string. Please
how to convert string to double in java
how to convert string to double in java  Hi, I have String variable with double value in it. how to convert string to double in java? Thanks  ... to convert a String into double. Here is full example code: package net.roseindia
how to convert string to double in java
how to convert string to double in java  Hi, I have String variable with double value in it. how to convert string to double in java? Thanks  ... to convert a String into double. Here is full example code: package net.roseindia
how to convert string to double in java
how to convert string to double in java  Hi, I have String variable with double value in it. how to convert string to double in java? Thanks  ... to convert a String into double. Here is full example code: package net.roseindia
how to convert string to double in java
how to convert string to double in java  Hi, I have String variable with double value in it. how to convert string to double in java? Thanks  ... to convert a String into double. Here is full example code: package net.roseindia
How to convert String to int in Java
How to convert String to int in Java  Hi, I have String with int value in it. I want to know the source code to convert this String value into the int variable. How to convert String to int in Java? Thanks   Hi
How to convert String to int in Java
How to convert String to int in Java  Hi, I have String with int value in it. I want to know the source code to convert this String value into the int variable. How to convert String to int in Java? Thanks   Hi
How to convert String to int in Java
How to convert String to int in Java  Hi, I have String with int value in it. I want to know the source code to convert this String value into the int variable. How to convert String to int in Java? Thanks   Hi
How to convert String to int in Java
How to convert String to int in Java  Hi, I have String with int value in it. I want to know the source code to convert this String value into the int variable. How to convert String to int in Java? Thanks   Hi
How ro convert char into string??
How ro convert char into string??  Suppose i have one array like... char [] ch={'H','E','L','L','o'}; now i want to convert this arrar into string... is for java...but i want this in c# How ro convert char into string using recursive
How to convert Arraylist into String Array Java
How to convert Arraylist into String Array Java  Hi, I am beginners of Java programming. Can somebody Suggest me how to convert arraylist to string... information with example. You can find the online example of how to convert arraylist
how to convert string to char array in Java
how to convert string to char array in Java  Hi, I have a string in Java which has to be converted to char array. What are the options to convert String object to char Array in Java? how to convert string to char array
How to convert date to string in Java in yyyy-mm-dd format
How to convert date to string in Java in yyyy-mm-dd format  Hi, I... to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... SimpleDateFormat("yyyy-mm-dd"); Then use the format function to DateFormat to convert
How to convert Input Stream to String in java
How to convert Input Stream to String in java The InputStream class... based data, one byte at a time. In this section, you will learn how to convert InputStream into string.  Description of code: Since class
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... to format string to date. Here is the full example code: package net.roseindia
Please tell me how can i convert string to timer
Please tell me how can i convert string to timer  Please tell me how can i convert string to timer
How to convert a stack trace to a string?
Example of converting StackTrace to String in Java Program In this tutorial we are going to learn different ways to convert StackTrace to String in Java... can also be used to convert stack trace to String in Java. Here is an example
How to convert a stack trace to a string?
Example of converting StackTrace to String in Java Program In this tutorial we are going to learn different ways to convert StackTrace to String in Java... can also be used to convert stack trace to String in Java. Here is an example
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
how to convert string to char array in java without using tochararray
how to convert string to char array in java without using tochararray  Hi, I want to convert the String object in java without the toChararray() function. how to convert string to char array in java without using
convert string to date nsdate
convert string to date nsdate  Hi, How to convert c string to date NSDate?   Convert NSDate to NSString
Convert String to Number
Convert String to Number       In this section, we will learn how to convert String to Number. The following program provides you the functionality to convert String
How to convert String Date to Timestamp in Java?
. In this example program we are going to convert String representation of Date object... is the full code of the program to convert Date String format to Timestamp... Convert Date to Timestamp Convert String to Date
Read/Convert an inputStream to a String
in Java and convert it to a String. what is the best code for for this? How to Read/Convert an inputStream to a String? My object is of java.io.InputStream...://www.roseindia.net"; //Convert String into InputStream InputStream

Ads