Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.format.Time;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.TimeZone;

public class Main {
    public static String getTimeAndDate(long j) {
        try {
            Calendar instance = Calendar.getInstance();
            TimeZone timeZone = TimeZone.getDefault();
            instance.setTimeInMillis(j);
            instance.add(14, timeZone.getOffset(instance.getTimeInMillis()));
            String format = new SimpleDateFormat(" dd, MMM yyyy").format(instance.getTime());
            Time time = new Time();
            time.set(j);
            return time.format("%H:%M") + format;
        } catch (Exception e) {
            return "";
        }
    }
}