/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TestRest.converter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
/**
 *
 * @author aparnab
 */
public class TimeConverter {
    private String value;

    public TimeConverter(){
    }
    
    @XmlElement(name="value")
    public String getTime(){
        return this.value;
    }
    public void setTime(Long itime){
        Date tempDate;
        //Date retrieved from db is in UTC, add pacific time diff to bring it to current time zone
        Long pacificTimeDifference = 8 * 60 * 60 * 1000L;
        //multiply by 1000 to convert into milliseconds as Date() expects ms
        tempDate = new Date((itime *1000) + pacificTimeDifference);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
        this.value = formatter.format(tempDate);        
    }

}
