Answers for "get current date time in milliseconds java"

3

java get current milliseconds

package com.tutorialspoint;

import java.lang.*;

public class SystemDemo {

   public static void main(String[] args) {

      // returns the current time in milliseconds
      System.out.print("Current Time in milliseconds = ");
      System.out.println(System.currentTimeMillis());
   }
}
Posted by: Guest on June-20-2020
0

date to milliseconds java

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

public class HelloWorld{

     public static void main(String []args){

		String myDate = "2020-02-26 03:57:35";
		LocalDateTime localDateTime = LocalDateTime.parse(myDate,
		    DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") );
		    
		    long millis = localDateTime
		    .atZone(ZoneId.of("America/Chicago")) //optional
		    .toInstant().toEpochMilli();
    
		System.out.println(millis);
     }
}
Posted by: Guest on January-06-2021

Code answers related to "get current date time in milliseconds java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language