Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.sql.Date;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class Main {
    /**
     * Helper method to get the date and time from timestamp. Converts the Timestamp in Milliseconds to Date and Time and then
     * formats the Date object with {@link Format} and returns the String of Date and Time.
     *
     * @return
     */
    public static String getFullDateAndTime(long timestamp) {
        Date date = new Date(timestamp);
        Format dateFormat = new SimpleDateFormat("EEEE, dd MMMM yyyy, hh:mm a", Locale.US);
        return dateFormat.format(date);
    }
}