- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 input in Java
UseSimpleDateFormat('dd-MMM-yy') for string date.
Format dateFormatter = new SimpleDateFormat("dd-MMM-yy");
For above class, do not forget to import the following package, else an error would be visible.
import java.text.SimpleDateFormat;
Now, parse the date.
Date dt = (Date) dateFormatter.parseObject("20-Nov-18");
Example
import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { Format dateFormatter = new SimpleDateFormat("dd-MMM-yy"); // parse Date dt = (Date) dateFormatter.parseObject("20-Nov-18"); System.out.println("Date = "+dt); } }
Output
Date = Tue Nov 20 00:00:00 UTC 2018
- Related Articles
- Parse string date time value input in Java
- Java Program to parse string date value with default format
- Format and Parse Date in Java
- How to parse date sting to date in Java?
- Java Program to parse date and time
- AngularJS and HTML5 date input value - how to get Firefox to show a readable date value in a date input?
- HTML DOM Input Date value Property
- How to create Date object from String value in Java?
- Parse Octal string to create BigInteger in Java
- Parse decimal string to create BigInteger in Java
- Parse hexadecimal string to create BigInteger in Java
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- How to parse date in MySQL?
- How to parse date in JSP?
- Parse a string to a Boolean object in Java

Advertisements