Answer the question
In order to leave comments, you need to log in
How to convert String to Date WITHOUT format change?
Hi all. There is a string 05/01/2020, you need to convert it to Date. I use SimpleDateFormat with the mask dd.MM.yyyy, at the output I get words, time zone, time instead of the original date. How to make a normal date, which was?
DateS = '01.05.2020'
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
Date dateD = format.parse(DateS)
Answer the question
In order to leave comments, you need to log in
If you want structure to match your string then use LocalDate instead of Date
detailed info - https://metanit.com/java/tutorial/12.3.php
public static void main(String[] args) throws ParseException {
var dates = "01.05.2020";
var format = new SimpleDateFormat("dd.MM.yyyy");
var dateD = format.parse(dates);
System.out.println(dateD);
}
Fri May 01 00:00:00 MSK 2020
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question