Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get time stamp java

 // 2021-03-24 16:48:05.591
  Timestamp timestamp = new Timestamp(System.currentTimeMillis());

  // 2021-03-24 16:48:05.591
  Date date = new Date();
  Timestamp timestamp2 = new Timestamp(date.getTime());

  // convert Instant to Timestamp
  Timestamp ts = Timestamp.from(Instant.now())

  // convert ZonedDateTime to Instant to Timestamp
  Timestamp ts = Timestamp.from(ZonedDateTime.now().toInstant()));

  // convert Timestamp to Instant
  Instant instant = ts.toInstant();
Comment

how to get current date stamp in java

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

public class SimpleTesting{
    public static void main(String[] args) {
        SimpleDateFormat date = new SimpleDateFormat("yyyy.MM.dd.HH:mm:ss");
        String timeStamp = date.format(new Date());
        System.out.println("Current Time Stamp: "+timeStamp);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: convert string to byte java 
Java :: java regex ip 
Java :: get boolean from string java 
Java :: change color of jframe 
Java :: java how to override a private method 
Java :: how to instantiate hashmap in java 
Java :: char cannot be converted to string 
Java :: sort string java 
Java :: android videoview setup 
Java :: resource leak java 
Java :: sorting hashmap by key in java 8 
Java :: encode file to base64 java 
Java :: java foreach list 
Java :: hanoi tower java 
Java :: how to set title in center in toolbar in android 
Java :: how to print array 
Java :: java create new thread 
Java :: change height of row at JTable 
Java :: char array to string java 
Java :: array to arraylist java 
Java :: java sort list of strings 
Java :: optional throw if present 
Java :: how to access variable from another class in java 
Java :: iterator java 
Java :: binding fragment android 
Java :: comment in java 
Java :: java example 
Java :: can we create a class inside a class in java 
Java :: java replace all not number 
Java :: java detect new line in string 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =