package com.dev.swms.server.action.formatter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.dev.swms.server.utils.DateUtils;
import com.dev.energy.server.format.Formatter;

public class InventoryAgeFormatter implements Formatter {

	public String format(String property, Object storageDate, List origenData,
			String referenceModel, String locale) {
		if(storageDate instanceof Date) {
			return String.valueOf(DateUtils.getBetweenDays((Date) storageDate, new Date()));
		}else{
			try {
				return String.valueOf(DateUtils.getBetweenDays(new SimpleDateFormat("yyyy-MM-dd").parse(storageDate.toString()), new Date()));
			} catch (ParseException e) {
				e.printStackTrace();
				return "-";
			}
		}
	}

}
