Returns a new Date instance representing the object.
969857
public Date makeDateFrom( Object obj )
  {
    if( obj == null )
    {
      return null;
    }

    if( obj instanceof IDimension )
    {
      obj = ((IDimension)obj).toNumber();
    }

    if( obj instanceof Date )
    {
      return (Date)obj;
    }

    if( obj instanceof Number )
    {
      return new Date( ((Number)obj).longValue() );
    }

    if( obj instanceof Calendar)
    {
      return ((Calendar)obj).getTime();
    }

    if( !(obj instanceof String) )
    {
      obj = obj.toString();
    }

    try
    {
      return parseDateTime( (String)obj );
    }
    catch( Exception e )
    {
      //e.printStackTrace();
    }

    return null;
  }
1306694
function coerceDate(value) {
    if (value instanceof Date) {
        return value;
    }

    let timestamp = Date.parse(value);

    if (!isNaN(timestamp)) {
        return new Date(timestamp);
    }

    return value;
}
569988
function(obj) {
    _.forEach(obj, function(val, key) {
      if (_.isString(val)) {
        if (Mixins.isObjectId(val)) {
          obj[key] = Mixins.newObjectId(val);
        } else if (Mixins.isValidISO8601String(val)) {
          obj[key] = new Date(val);
        }
      } else if (_.isDate(val)) {
        obj[key] = val;
      } else if (_.isObject(val)) {
        if (val['$oid']) {
          obj[key] = val['$oid'];
        } else {
          obj[key] = this.cast(val);
        }
      }
    }.bind(this));

    return obj;
  }
1170890
public Date getTo() {
        Long to = null;
        for (final TimeInterval interval : intervals) {
            if (to == null) {
                to = interval.getTo();
            } else {
                to = Math.max(interval.getTo(), to);
            }
        }
        if (to != null) {
            return new Date(to);
        }
        return null;
    }
640615
public CmsJspInstanceDateBean getToInstanceDate() {

        if (m_instanceDate == null) {
            m_instanceDate = new CmsJspInstanceDateBean(getToDate(), m_cms.getRequestContext().getLocale());
        }
        return m_instanceDate;
    }
1124838
def _format_date(self, obj) -> str:
        
        if obj is None:
            return ''
        if isinstance(obj, datetime):
            obj = obj.date()
        return date_format(obj, 'SHORT_DATE_FORMAT')
543385
def from_date(self, value: date) -> datetime:
        
        assert isinstance(value, date)

        #self.value = datetime.combine(value, time.min)
        self.value = datetime(value.year, value.month, value.day)
        return self.value
193835
public static Date newRandomDate(final Date from)
	{
		final Random secrand = new SecureRandom();
		final double randDouble = -secrand.nextDouble() * from.getTime();
		final double randomDouble = from.getTime() - secrand.nextDouble();
		final double result = randDouble * randomDouble;
		return new Date((long)result);
	}
1208373
public static final Parser<Date> instance() { // NOPMD it's thread save!
    if (TimeParser.instanceParser == null) {
      synchronized (TimeParser.class) {
        if (TimeParser.instanceParser == null) {
          TimeParser.instanceParser = new TimeParser("HH:mm:ss");
        }
      }
    }
    return TimeParser.instanceParser;
  }
1140936
function copy(x) {
    switch (getType(x)) {
    case "[object Array]":
      return copyArray(x);

    case "[object Object]":
      return copyObject(x);

    // TODO is this necessary ?
    case "[object Date]":
      return new Date(x.getTime());

    default:
      return x;
    }
  }
961102
function getNow(context = {}) {
  const result = (context.ntlctx || {}).now;
  if (result instanceof Date) {
    return result;
  }
  return new Date();
}
266608
protected Date massageDate (Object arg)
    {
        if (arg instanceof Long) {
            return new Date(((Long)arg).longValue());
        } else if (arg instanceof Date) {
            return (Date)arg;
        } else if (arg instanceof Calendar) {
            return ((Calendar)arg).getTime();
        } else {
            System.err.println("Date provided with invalid argument " +
                               "[arg=" + arg + ", aclass=" +
                               StringUtil.shortClassName(arg) + "].");
            return null;
        }
    }
83708
public static Date fromJavaUtilDate(java.util.Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    return new Date(
        cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
  }
679642
public static DateFormat getInstance() {
        if (instance == null) {
            synchronized (instanceLock) {
                if (instance == null) {
                    instance = new ResqueDateFormatThreadLocal();
                }
            }
        }
        return instance.get();
    }
1143035
public Date toDate() {
    long secondsInMilliseconds = TimeUnit.SECONDS.toMillis(this.seconds);
    long nanosInMilliseconds = TimeUnit.NANOSECONDS.toMillis(this.nanos);
    return new Date(secondsInMilliseconds + nanosInMilliseconds);
  }
1169974
public Date getDate() {
        if (date == null) {
            if (getContext() != null) {
                date = context.now();
            }
        }
        return date;
    }
559451
public Date getFrom() {
        final TimeInterval first = intervals.first();
        if (first != null) {
            return new Date(first.getFrom());
        }
        return null;
    }