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.Calendar;
import java.util.Date;

public class Main {
    public static String convertLongToString(long time, String format) {
        String myDate = null;
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern(format);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(time);
        Date date = calendar.getTime();
        myDate = sdf.format(date);
        return myDate;
    }
}