Java Simple Date Format


Paul's Blog On Software Development

A reminder of how to format a date for display:

1. Set the date format required

private static SimpleDateFormat dateDisplayFormat = new SimpleDateFormat(“dd MMM yyyy”);

2. Apply the date format

public String makePageTitleForBrowserTab(Date date, String title, Integer number) {
String pageTitle = “”;
if (date != null){
pageTitle += dateDisplayFormat.format(date);
}
if (title != null){
pageTitle += ” – ” + title;
}
if(number != null){
pageTitle += ” – p” + number;
}
return pageTitle;
}

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s