get Pretty Date Time - Java java.util

Java examples for java.util:Date Format

Description

get Pretty Date Time

Demo Code


//package com.java2s;
import java.text.DateFormat;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar date = Calendar.getInstance();
        System.out.println(getPrettyDateTime(date));
    }//  w w  w . jav a2 s. c  o m

    public static String getPrettyDateTime(Calendar date) {
        DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(
                DateFormat.LONG, DateFormat.SHORT);
        return dateTimeFormat.format(date.getTime());
    }
}

Related Tutorials