Create Calendar from long value and format as dd/MM/yyyy hh:mm:ss a - Android java.util

Android examples for java.util:Calendar Format

Description

Create Calendar from long value and format as dd/MM/yyyy hh:mm:ss a

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    public static String getDate(long milliSeconds) {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "dd/MM/yyyy hh:mm:ss a");
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(milliSeconds);
        return formatter.format(calendar.getTime());
    }//  www  .j  a  va2  s  .  c o m
}

Related Tutorials