- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 time value input in Java
In Java, you can parse string date time value input using
SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
We have used the above class since we imported the following package −
import java.text.SimpleDateFormat;
Now, we can display the date in the same format −
Date dt = (Date) dateFormatter.parseObject("Tue, 20 Nov 2018 16:10:45 -0530");
The following is an example −
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("E, dd MMM yyyy HH:mm:ss Z"); Date dt = (Date) dateFormatter.parseObject("Tue, 20 Nov 2018 16:10:45 -0530"); System.out.println(dt); } }
Output
Tue Nov 20 21:40:45 UTC 2018
- Related Articles
- Parse string date value input in Java
- Java Program to parse string date value with default format
- Java Program to parse date and time
- Format and Parse Date in Java
- How to parse date sting to date in Java?
- 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?
- Java Program to parse Time using custom format
- Parse Octal string to create BigInteger in Java
- Parse decimal string to create BigInteger in Java
- Parse hexadecimal string to create BigInteger in Java
- HTML DOM Input Time value Property
- How to parse Date from String in the format: dd/MM/yyyy to dd/MM/yyyy in java?
- How to parse date in MySQL?

Advertisements