Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

How to convert timestamp to time in java

//Timestamp to HH:mm:ss format
Long Timestamp = 1633304782;
Date timeD = new Date(Timestamp * 1000);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

String Time = sdf.format(timeD);

//RESULT this code convert 1633304782 to 05:46:33
Comment

timestamp to date java

String timestampToDate(long timestamp, String pattern)
    {
        Date timeD = new Date(timestamp);
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(timeD);
    }

//You can use this for both date or time.
// long timestamp = System.currentTimeMillis();
// eg: for date use it like this:
//timestampToDate(timestamp, "dd MMM, yyyy");
// eg: for time use it like this:
//timestampToDate(timestamp, "hh:mm a");
// eg: for both:
//timestampToDate(timestamp, "dd MMM, yyyy - hh:mm a");
Comment

date to timestamp java

All you need to do is change the string within the java.text.SimpleDateFormat constructor to: "MM-dd-yyyy HH:mm:ss".

Just use the appropriate letters to build the above string to match your input date.
Comment

PREVIOUS NEXT
Code Example
Java :: findview by id in android 
Java :: comparable 
Java :: split each character in a string (java) 
Java :: java use of super keyword 
Java :: rotate matrix in java 
Java :: java method exercises 
Java :: instanceof operator java 
Java :: final class java 
Java :: final method java 
Java :: java @override 
Java :: Linked list implementation in Java source code 
Java :: button event 
Java :: springboot avoid generated security password: 
Java :: use of getclass()in string 
Java :: java button with jpg image 
Java :: im retarded 
Java :: how to get history stack in android webview 
Sql :: sql developer search all packages for text 
Sql :: stop mysql server mac 
Sql :: alter user mysql native password 
Sql :: mysql alter column default 
Sql :: print oracle 
Sql :: postgresql generate uuid 
Sql :: sql server beginning of month 
Sql :: postgres remove database 
Sql :: psql connections 
Sql :: show indexes in mql 
Sql :: import sql mysql ubuntu 
Sql :: mysql get last day of month 
Sql :: mysql connection with sqlalchecmy 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =