Java Code Examples for java.text.DateFormat.clone()

The following are Jave code examples for showing how to use clone() of the java.text.DateFormat class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Equella   File: ThreadSafeSimpleDateFormat.java   Source Code and License Vote up 6 votes
public Date parse(String date, TimeZone tz, Locale locale) throws ParseException
{
	DateFormat format = aquire(locale);
	try
	{
		if( tz == null )
		{
			return format.parse(date);
		}
		else
		{
			// need to mutate the format...
			DateFormat clone = (DateFormat) format.clone();
			clone.setTimeZone(tz);
			return clone.parse(date);
		}
	}
	finally
	{
		release(format, locale);
	}
}