format Locale Date using android DateFormat - Android android.text.format

Android examples for android.text.format:DateFormat

Description

format Locale Date using android DateFormat

Demo Code


//package com.java2s;

import android.content.Context;

import android.text.format.DateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /**/*from  w  ww .java 2s . c  o  m*/
     @param time input in milliseconds TODO: covert to seconds
     */
    public static String formatLocaleDate(Context context, long time) {
        java.text.DateFormat df = DateFormat.getMediumDateFormat(context);
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
        return df.format(new Date(time));
    }
}

Related Tutorials