Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SimpleDateFormat 1

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
Hi,
I've specified a date format to be displayed (i.e. "HH:mm:ss" e.g. 14:47:32) and i want to be able to toggle this format with the use of one button to a 12 hr format (i.e "hh:mm:ss a" e.g 02:47:32 PM). I was wondering if it is possible to get the current format to know which format to change it to.

So:
if (formatter.? == "HH:mm:ss")
//what is the method to retrieve the current format?
{
formatter = new SimpleDateFormat("hh:mm:ss a");
}
else
{
formatter = new SimpleDateFormat("HH:mm:ss")
}
 
formatter.toPattern() will give you what you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top