serialize a DateTime

@param dateTime DateTime to serialize
@param sb
@throws ConverterException
499742
private void _serializeDateTime(DateTime dateTime, StringBuilder sb) throws ConverterException {

	try {
	    TimeZone tz = ThreadLocalPageContext.getTimeZone();
	    sb.append(goIn());
	    sb.append("createDateTime(");
	    sb.append(DateFormat.call(null, dateTime, "yyyy,m,d", tz));
	    sb.append(',');
	    sb.append(TimeFormat.call(null, dateTime, "H,m,s,l,", tz));
	    sb.append('"').append(tz.getID()).append('"');
	    sb.append(')');
	}
	catch (PageException e) {
	    throw toConverterException(e);
	}
    }
659559
private void _serializeQuery(PageContext pc, Set test, Query query, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {

	ApplicationContextSupport acs = (ApplicationContextSupport) pc.getApplicationContext();
	boolean preserveCase = acs.getSerializationSettings().getPreserveCaseForQueryColumn(); // UPPERCASE column keys by default for Query

	Collection.Key[] _keys = CollectionUtil.keys(query);
	sb.append(goIn());
	sb.append("{");

	/*
	 * 
	 * {"DATA":[["a","b"],["c","d"]]} {"DATA":{"aaa":["a","c"],"bbb":["b","d"]}}
	 */
	// Rowcount
	if (serializeQueryByColumns) {
	    sb.append("\"ROWCOUNT\":");
	    sb.append(Caster.toString(query.getRecordcount()));
	    sb.append(',');
	}

	// Columns
	sb.append("\"COLUMNS\":[");
	String[] cols = query.getColumns();
	for (int i = 0; i < cols.length; i++) {
	    if (i > 0) sb.append(",");
	    sb.append(StringUtil.escapeJS(preserveCase ? cols[i] : cols[i].toUpperCase(), '"', charsetEncoder));
	}
	sb.append("],");

	// Data
	sb.append("\"DATA\":");
	if (serializeQueryByColumns) {
	    sb.append('{');
	    boolean oDoIt = false;
	    int len = query.getRecordcount();
	    pc = ThreadLocalPageContext.get(pc);
	    boolean upperCase = false;
	    if (pc != null) upperCase = pc.getCurrentTemplateDialect() == CFMLEngine.DIALECT_CFML && ((ConfigWebImpl) pc.getConfig()).getDotNotationUpperCase();

	    for (int i = 0; i < _keys.length; i++) {
		if (oDoIt) sb.append(',');
		oDoIt = true;
		sb.append(goIn());

		sb.append(StringUtil.escapeJS(upperCase ? _keys[i].getUpperString() : _keys[i].getString(), '"', charsetEncoder));
		sb.append(":[");
		boolean doIt = false;
		for (int y = 1; y <= len; y++) {
		    if (doIt) sb.append(',');
		    doIt = true;
		    try {
			_serialize(pc, test, query.getAt(_keys[i], y), sb, serializeQueryByColumns, done);
		    }
		    catch (PageException e) {
			_serialize(pc, test, e.getMessage(), sb, serializeQueryByColumns, done);
		    }
		}

		sb.append(']');
	    }

	    sb.append('}');
	}
	else {
	    sb.append('[');
	    boolean oDoIt = false;
	    int len = query.getRecordcount();
	    for (int row = 1; row <= len; row++) {
		if (oDoIt) sb.append(',');
		oDoIt = true;

		sb.append("[");
		boolean doIt = false;
		for (int col = 0; col < _keys.length; col++) {
		    if (doIt) sb.append(',');
		    doIt = true;
		    try {
			_serialize(pc, test, query.getAt(_keys[col], row), sb, serializeQueryByColumns, done);
		    }
		    catch (PageException e) {
			_serialize(pc, test, e.getMessage(), sb, serializeQueryByColumns, done);
		    }
		}
		sb.append(']');
	    }
	    sb.append(']');
	}
	sb.append('}');
    }
614864
private void _serializeComponent(PageContext pc, Set test, Component component, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
	ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, component);
	_serializeStruct(pc, test, cw, sb, serializeQueryByColumns, false, done);
    }
1372579
@Override
	public void serialize(BinderContext context, SerializerWrapper serializerWrapper, E object) throws Exception {
		serialize(context, object, serializerWrapper, true);
	}
1246045
function serializeAllDates(model, json) {
	_.each(json, function (value, name) {
		if ( _.isDate( value ) ) {
			json[ name ] = model.serializeDate( name, value );
		} else if ( !isScalar( value ) && !isBackboneInstance( value ) && isRecursive( value ) ) {
			serializeAllDates( model, value );
		}
	});

	return json;
}
579921
public void setDateTime(String dateTimeString)
    {
		Date dateTime = null;
		try	{
            if ((dateTimeString != null) && (dateTimeString.length() > 0))
                dateTime = dateTimeFormat.parse(dateTimeString);
		} catch (Exception e)	{
            dateTime = null;
		}
        this.setDateTime(dateTime);
    }
414310
private void _serializeList(List list, StringBuilder sb, Set<Object> done) throws ConverterException {

	sb.append(goIn());
	sb.append("[");
	boolean doIt = false;
	ListIterator it = list.listIterator();
	while (it.hasNext()) {
	    if (doIt) sb.append(',');
	    doIt = true;
	    _serialize(it.next(), sb, done);
	}

	sb.append(']');
    }
605125
def serialize_date(attr, **kwargs):
        
        if isinstance(attr, str):
            attr = isodate.parse_date(attr)
        t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day)
        return t
308631
@Override
    public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
        if (src == null) {
            return JsonNull.INSTANCE;
        } else {
            return new JsonPrimitive(apiClient.formatDatetime(src));
        }
    }
444625
def _serialize(self, value, *args, **kwargs):
        """"""
        if value is not None:
            value = super(MSTimestamp, self)._serialize(value, *args) * 1e3
        return value
808012
@Override
	public Long serialize(Date value) {
		if (value != null) {
			return value.getTime();
		}
		return null;
	}
754469
private void _serialize(Object object, StringBuilder sb, Set<Object> done) throws ConverterException {
	// try {
	deep++;
	// NULL
	if (object == null) {
	    sb.append(goIn());
	    sb.append("nullValue()");
	    deep--;
	    return;
	}
	// String
	if (object instanceof String) {
	    sb.append(goIn());
	    sb.append(QUOTE_CHR);
	    sb.append(escape(object.toString()));
	    sb.append(QUOTE_CHR);
	    deep--;
	    return;
	}
	if (object instanceof TimeZone) {
	    sb.append(goIn());
	    sb.append(QUOTE_CHR);
	    sb.append(escape(((TimeZone) object).getID()));
	    sb.append(QUOTE_CHR);
	    deep--;
	    return;
	}
	if (object instanceof Locale) {
	    sb.append(goIn());
	    sb.append(QUOTE_CHR);
	    sb.append(LocaleFactory.toString((Locale) object));
	    sb.append(QUOTE_CHR);
	    deep--;
	    return;
	}
	// Number
	if (object instanceof Number) {
	    sb.append(goIn());
	    sb.append(Caster.toString(((Number) object)));
	    deep--;
	    return;
	}
	// Boolean
	if (object instanceof Boolean) {
	    sb.append(goIn());
	    sb.append(Caster.toString(((Boolean) object).booleanValue()));
	    deep--;
	    return;
	}
	// DateTime
	if (object instanceof DateTime) {
	    _serializeDateTime((DateTime) object, sb);
	    deep--;
	    return;
	}
	// Date
	if (object instanceof Date) {
	    _serializeDate((Date) object, sb);
	    deep--;
	    return;
	}
	// XML
	if (object instanceof Node) {
	    _serializeXML((Node) object, sb);
	    deep--;
	    return;
	}
	if (object instanceof ObjectWrap) {
	    try {
		_serialize(((ObjectWrap) object).getEmbededObject(), sb, done);
	    }
	    catch (PageException e) {
		throw toConverterException(e);
	    }
	    deep--;
	    return;
	}
	// Timespan
	if (object instanceof TimeSpan) {
	    _serializeTimeSpan((TimeSpan) object, sb);
	    deep--;
	    return;
	}
	Object raw = LazyConverter.toRaw(object);
	if (done.contains(raw)) {
	    sb.append(goIn());
	    sb.append("nullValue()");
	    deep--;
	    return;
	}

	done.add(raw);
	try {
	    // Component
	    if (object instanceof Component) {
		_serializeComponent((Component) object, sb, done);
		deep--;
		return;
	    }

	    // Struct
	    if (object instanceof Struct) {
		_serializeStruct((Struct) object, sb, done);
		deep--;
		return;
	    }
	    // Map
	    if (object instanceof Map) {
		_serializeMap((Map) object, sb, done);
		deep--;
		return;
	    }
	    // Array
	    if (object instanceof Array) {
		_serializeArray((Array) object, sb, done);
		deep--;
		return;
	    }
	    // List
	    if (object instanceof List) {
		_serializeList((List) object, sb, done);
		deep--;
		return;
	    }
	    // Query
	    if (object instanceof Query) {
		_serializeQuery((Query) object, sb, done);
		deep--;
		return;
	    }
	    // String Converter
	    if (object instanceof ScriptConvertable) {
		sb.append(((ScriptConvertable) object).serialize());
		deep--;
		return;
	    }
	    if (object instanceof Serializable) {
		_serializeSerializable((Serializable) object, sb);
		deep--;
		return;
	    }
	}
	finally {
	    done.remove(raw);
	}
	throw new ConverterException("can't serialize Object of type [ " + Caster.toClassName(object) + " ]");
	// deep--;
	/*
	 * } catch(StackOverflowError soe){ throw soe; }
	 */
    }
1018020
public static StringBuilder appendTimes(StringBuilder sb, String append, int times) {
		
		for(;times>0; times--)
			sb.append(append);
		
		return sb;
	}
1024253
public Object stringToBinary(String tempString) throws Exception
    {
        java.util.Date dateOld = new java.util.Date((long)this.getValue());   // Save current time
        return DateConverter.stringToBinary(tempString, dateOld, DBConstants.TIME_ONLY_FORMAT);
    }
431777
def _serialize_value(self, value):
        

        if isinstance(value, datetime.datetime):
            return value.strftime(self.datetime_format)
        elif isinstance(value, datetime.date):
            return value.strftime(self.date_format)
        elif isinstance(value, datetime.time):
            return value.strftime(self.time_format)
        return text_type(value)
780571
@Override
	public Long serialize(Calendar value) {
		if (value != null) {
			return value.getTimeInMillis();
		}
		return null;
	}
620710
public void _serializeStruct(PageContext pc, Set test, Struct struct, StringBuilder sb, boolean serializeQueryByColumns, boolean addUDFs, Set<Object> done)
	    throws ConverterException {

	ApplicationContextSupport acs = (ApplicationContextSupport) pc.getApplicationContext();
	boolean preserveCase = acs.getSerializationSettings().getPreserveCaseForStructKey(); // preserve case by default for Struct

	// Component
	if (struct instanceof Component) {
	    String res = castToJson(pc, (Component) struct, NULL_STRING);
	    if (res != NULL_STRING) {
		sb.append(res);
		return;
	    }
	}

	sb.append(goIn());
	sb.append("{");

	Iterator<Entry<Key, Object>> it = struct.entryIterator();
	Entry<Key, Object> e;
	String k;
	Object value;
	boolean doIt = false;
	while (it.hasNext()) {

	    e = it.next();
	    k = e.getKey().getString();
	    if (!preserveCase) k = k.toUpperCase();
	    value = e.getValue();

	    if (!addUDFs && (value instanceof UDF || value == null)) continue;

	    if (doIt) sb.append(',');

	    doIt = true;
	    sb.append(StringUtil.escapeJS(k, '"', charsetEncoder));
	    sb.append(':');
	    _serialize(pc, test, value, sb, serializeQueryByColumns, done);
	}

	if (struct instanceof Component) {
	    Boolean remotingFetch;
	    Component comp = (Component) struct;
	    boolean isPeristent = false;
	    isPeristent = comp.isPersistent();

	    Property[] props = comp.getProperties(false, true, false, false);
	    ComponentScope scope = comp.getComponentScope();
	    for (int i = 0; i < props.length; i++) {
		if (!ignoreRemotingFetch) {
		    remotingFetch = Caster.toBoolean(props[i].getDynamicAttributes().get(REMOTING_FETCH, null), null);
		    if (remotingFetch == null) {
			if (isPeristent && ORMUtil.isRelated(props[i])) continue;
		    }
		    else if (!remotingFetch.booleanValue()) continue;

		}
		Key key = KeyImpl.getInstance(props[i].getName());
		value = scope.get(key, null);
		if (!addUDFs && (value instanceof UDF || value == null)) continue;
		if (doIt) sb.append(',');
		doIt = true;
		sb.append(StringUtil.escapeJS(key.getString(), '"', charsetEncoder));
		sb.append(':');
		_serialize(pc, test, value, sb, serializeQueryByColumns, done);
	    }
	}

	sb.append('}');
    }