1public String getCurrentTimeStamp() {
2 return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
3}
1import java.time.LocalDateTime;
2import java.time.ZoneId;
3import java.time.format.DateTimeFormatter;
4import java.text.DateFormat;
5import java.text.SimpleDateFormat;
6import java.util.*;
7
8public class HelloWorld{
9
10 public static void main(String []args){
11
12 String myDate = "2020-02-26 03:57:35";
13 LocalDateTime localDateTime = LocalDateTime.parse(myDate,
14 DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") );
15
16 long millis = localDateTime
17 .atZone(ZoneId.of("America/Chicago")) //optional
18 .toInstant().toEpochMilli();
19
20 System.out.println(millis);
21 }
22}