/*
 * 日期转换
 */
var DateConvert = {
	
	stringToDate : function(_strDate)
	{
		if ( _strDate.length < 8 )
		{
			return null ;
		}
		if (_strDate != '') {
			return new Date(Date.parse(_strDate.replace(/-/g,"/")));   
		}
		return null;
	},
	
	stringToDateUTC : function(_strDate)
	{
		if (_strDate == '') return null;
		return Date.parse(_strDate.replace(/-/g,"/"));
	},
	
	DateToUTC : function(_Date)
	{
		if ( _Date != null )
		{
			var _k = new Date();
			_k = _Date;
			return Date.UTC(_k.getYear(),_k.getMonth(),_k.getDate(),_k.getHours(),_k.getSeconds(),_k.getMinutes());
		}
		return null ;
	},
	
	DateToString : function(_Date)
	{
		var _now = new Date();
		_now = _Date ;
		var _b = _now.getFullYear().toString() + '-' + (_now.getMonth()>= 9 ? '':'0') + (_now.getMonth()+1).toString() + '-' + (_now.getDate()>=10 ? '':'0') + _now.getDate().toString();
		if (_b.length == 8)
			_b = '19' + _b;
		return _b ;
	},
	
	DateToFullString : function(_Date)
	{
		var _now = new Date();		
		_now = _Date ;
		var _b = _now.getFullYear().toString()+ (_now.getMonth()>= 9 ? '':'0') + (_now.getMonth()+1).toString()  + (_now.getDate()>=10 ? '':'0') + _now.getDate().toString();
		_b+=_now.getHours().toString()+_now.getMinutes().toString()+_now.getSeconds()+Math.floor((_now.getMonth()+3)/3).toString()+_now.getMilliseconds().toString();
		return _b ;
	},
	
	UTCToString : function(_utc)
	{
		var _date = new Date(_utc);
		return this.DateToString(_date);
	},
	
//	StringToDateType : function(_strDate)
//	{
//		if (_strDate == '') return null;
//		var _k = new leaputil.newJson(DateType); 
//		_k.time = this.stringToDateUTC(_strDate);
//		return _k ;
//	},
	StringToDateType : function(_strDate)
	{
		if (_strDate == '') return null;
		var _k = new JavaDate(); 
		_k.time = this.stringToDateUTC(_strDate);
		return _k ;
	},
	
	DateToDateType : function( _date )
	{
		var _k = new JavaDate();
		_k.time = this.DateToUTC(_date);
		return _k ;
	},
	
	DateTypeToString : function(_date)
	{
		if (_date == null) return '';
		if (_date.time == null) return '';
		return this.UTCToString(_date.time);
		
	},
/*****************************************************************   
          Name DateCompare   
          Purpose 计算两个字符(YYYY-MM-DD)日期相隔天数   
          Param asStartDate     起始日期   
                        asEndDate         终止日期   
          Return 字符串   
*****************************************************************/   
    DateCompare : function(asStartDate,asEndDate)
    {
      var miStart=Date.parse(asStartDate.replace(/\-/g,'/'));   
      var miEnd=Date.parse(asEndDate.replace(/\-/g,'/'));
      var result = (miEnd-miStart)/(1000*24*3600);
      return result + 1;
    },
     DateCompare_year : function(asStartDate,asEndDate)
    {
      var miStart=Date.parse(asStartDate.replace(/\-/g,'/'));   
      var miEnd=Date.parse(asEndDate.replace(/\-/g,'/'));
      var result = (miEnd-miStart)/(1000*24*3600)/365;
      return result;
    }
};
var DateType = {
	"javaClass" : "java.util.Date",
	"time" : null
};
