org.semanticwb.base.util.SimpleDateFormatTS Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SWBBase Show documentation
Show all versions of SWBBase Show documentation
Code utilities for SemanticWebBuilder
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.semanticwb.base.util;
import java.text.ParseException;
import java.util.Date;
/**
*
* @author javier.solis.g
*/
public class SimpleDateFormatTS
{
private final ThreadLocal sd;
public SimpleDateFormatTS(final String patern)
{
sd = new ThreadLocal()
{
@Override
protected java.text.SimpleDateFormat initialValue()
{
return new java.text.SimpleDateFormat(patern);
}
};
}
public Date parse(String txt) throws ParseException
{
return sd.get().parse(txt);
}
public String format(Date date)
{
return sd.get().format(date);
}
}