Hey guys in this short article, you will learn how to convert the String into datetime with time zone in Java.
Read More:
- Check the Complete Spring MVC Tutorials
- Check the Complete JSP Tutorials
- Check the Complete Spring Boot Tutorials [100+ Examples]
- Check the Complete Spring Boot and Thymeleaf Tutorial
- Check the Complete AWS Tutorial
- Check the Complete JavaServer Faces (JSF) Tutorial
- Check the Complete Spring Data JPA Tutorial
- Check the Complete Spring Security Tutorial
- Check the Javascript Projects for Beginners
- Check the Spring Boot JdbcTemplate Tutorials
To convert String into date we need to use parse()
method on the SimpleDateFormat()
object.
Date d = simpleDateFormat.parse("2021-12-31");
Convert date to dd/MM/yyyy format
public class ConvertStringToDate {
public static void main(String[] args) {
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
String date = "2021-12-31";
Date t;
try {
t = ft.parse(date);
System.out.println(t);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
Output:
Fri Dec 31 00:00:00 IST 2021
That’s it for this post, if you like this post, share this with your friends and colleagues or you can share this within your social media platform. Thanks, I will see you in our next post.
Our Best Partners:
nettikasinot ilman rekisteröitymistä
mines mina
lucky jet game
suomalaiset nettikasinot ilman rekisteröitymistä
viro kasinot
crazy time statistik
https://luckyjetwins.com/promocode/
lucky jet predictor online
https://crazytime-bangladesh.com/review/mostbet-casino/
demo rabbit fortune