All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.semanticwb.base.util.SimpleDateFormatTS Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy