Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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");
 
PREVIOUS NEXT
Tagged: #timestamp #date #java
ADD COMMENT
Topic
Name
3+9 =