Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class CurrentTime2 {
- public static void main(String[] args) {
- Date today = new Date();
- System.out.println(today); // Sun Nov 18 10:37:13 KST 2018
- SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat time = new SimpleDateFormat("hh:mm:ss a");
- System.out.println("Date: "+date.format(today)); // Date: 2018-11-18
- System.out.println("Time: "+time.format(today)); // Time: 10:40:22 AM
- }
- }
Add Comment
Please, Sign In to add comment