Date, SimpleDateFormat

package com.main;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
public static void main(String[] args) throws Exception {
String dateStr = "2021-03-29 18:29:02";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = sdf.parse(dateStr);
System.out.println(date.getTime());
Date d = new Date(1617028142000l);
System.out.println(d);
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf2.format(d));
Date now = new Date();
System.out.println(now);
}
}

Комментарии

Популярные сообщения из этого блога

Lesson1: JDK, JVM, JRE

SE_21_Lesson_11: Inheritance, Polymorphism

SE_21_Lesson_9: Initialization Blocks, Wrapper types, String class