Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- public class Main {
- public static void main(String[] args) {
- LocalDateTime myDate = LocalDateTime.now();
- System.out.println("Before formatting : " + myDate);
- DateTimeFormatter myFormatDate = DateTimeFormatter.ofPattern("dd-MM-yyyy");
- String myFormattedDate = myDate.format(myFormatDate);
- System.out.println("After formatting : " + myFormattedDate);
- DateTimeFormatter anotherFormatDate = DateTimeFormatter.ofPattern("HH-mm-ss");
- String anotherFormatToMyDate = myDate.format(anotherFormatDate);
- System.out.println("After another format date : " + anotherFormatToMyDate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement