Monday, February 18, 2019

java - How does the Date type get the 'YY-MM-DD'?

You can do it by the below code.



public void getCurrentTimeStampInYYMMDDFormat() {
String date = new SimpleDateFormat("yy-MM-dd").format(new Date());
}



If you are using JDK8 then, you can also do it like this:



public void getCurrentTimeStampInYYMMDDFormat() {
String date = LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yy-MM-dd"));
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...