package org.ofbiz.utils;

import java.util.Date;

import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.ObjectType;
import org.ofbiz.opentravelsystem.UtilValidate;

public class Utils {
	public static Date getDateFromString(String rawDate) throws GeneralException{
		String dateStr = rawDate;
		dateStr = dateStr.trim();
		if(dateStr != null && dateStr.length() > 10){
			dateStr = rawDate.substring(0, 10);
	    }
		if(!UtilValidate.isDate(dateStr, "yyyy-MM-dd")) dateStr =null;
		
		return (Date) ObjectType.simpleTypeConvert(dateStr , "Date", null, null);
	}
}
