
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Parse String Date Value with Default Format in Java
For default format, use −
DateFormat.getDateInstance(DateFormat.DEFAULT)
To parse the string date value, use the parse() method
Date dt = DateFormat.getDateInstance(DateFormat.DEFAULT).parse("Nov 19, 2018");
The following is an example −
Example
import java.text.DateFormat; import java.util.Date; public class Demo { public static void main(String[] argv) throws Exception { // parse date Date dt = DateFormat.getDateInstance(DateFormat.DEFAULT).parse("Nov 19, 2018"); System.out.println("Date: "+dt); } }
Output
Date: Mon Nov 19 00:00:00 UTC 2018
Advertisements