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.TimeZone;

public class Main {
    public static String getDateString(long time) {
        Calendar date = Calendar.getInstance();
        time = time * 1000;
        long targetTime = time - TimeZone.getDefault().getRawOffset();
        date.setTimeInMillis(targetTime);

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = dateformat.format(date.getTime());
        return dateString;
    }
}