FormatDateDef

// Format
Date date = new Date();

String s = DateFormat.getDateInstance(DateFormat.SHORT).format(date);
// 2/16/02

s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);
// Feb 16, 2002

s = DateFormat.getDateInstance(DateFormat.LONG).format(date);
// February 16, 2002

s = DateFormat.getDateInstance(DateFormat.FULL).format(date);
// Saturday, February 16, 2002

// This is same as MEDIUM
s = DateFormat.getDateInstance().format(date);
// Feb 16, 2002

// This is same as MEDIUM
s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(date);
// Feb 16, 2002

// Parse
try {
    date = DateFormat.getDateInstance(DateFormat.DEFAULT).parse("Feb 16, 2002");
} catch (ParseException e) {
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.