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 :: remove new line in string of java 
Java :: android studio close app 
Java :: java convert list to page 
Java :: cloning of list in java 
Java :: how to not open key board on start 
Java :: Java Copying Arrays Using copyOfRange() method 
Java :: generate a random phone number in java 
Java :: java date time 
Java :: sort string java 
Java :: java get number of days in month 
Java :: convert double to in in java 
Java :: java write 
Java :: how to make an activity default in android studio 
Java :: java get random char from alphabet 
Java :: how to destroy activity in android 
Java :: android studio textbox change text 
Java :: how to check my java heap space size 
Java :: loop list java 
Java :: java sort list 
Java :: get certain character from string java 
Java :: java create file if not exists 
Java :: java expressions 
Java :: selenide wait 
Java :: how to add elements to an array in java dynamically 
Java :: sorting the characters in a String in java 
Java :: how to control clip volume java 
Java :: java output array lists to file 
Java :: get last index of array java 
Java :: java stream min 
Java :: how to detect device javascirpt 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =