Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static String getDate(String integer) {
        SimpleDateFormat sdf = new SimpleDateFormat("EEEE,MMMM d,yyyy h:mm,a", Locale.ENGLISH);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        String formattedDate = sdf.format(new Date());
        if (!integer.equalsIgnoreCase("null")) {
            long seconds = Integer.valueOf(integer);
            long millis = seconds * 1000;
            Date date = new Date(millis);
            formattedDate = sdf.format(date);
            return formattedDate;
        }
        return formattedDate;

    }
}