List of usage examples for jdk.nashorn.internal.objects NativeDate getTime
@Function(attributes = Attribute.NOT_ENUMERABLE) public static double getTime(final Object self)
From source file:com.mongodb.jvm.json.nashorn.NativeDateEncoder.java
License:Apache License
public void encode(Object object, JsonContext context) throws IOException { double date = NativeDate.getTime(object); HashMap<String, Object> map = new HashMap<String, Object>(); map.put("$date", date); new MapEncoder().encode(map, context); }
From source file:com.threecrickets.jvm.json.nashorn.util.NashornNativeUtil.java
License:Mozilla Public License
public static Object from(ScriptObject scriptObject) { if (scriptObject instanceof NativeDate) { Double time = NativeDate.getTime(scriptObject); return new Date(time.longValue()); } else if (scriptObject instanceof NativeString) return scriptObject.toString(); return null;// w ww . j av a 2s . c o m }
From source file:io.lightlink.excel.WritingExcelStreamVisitor.java
License:Open Source License
protected void handleBinding(String property, RowNode rowNode, int i, RowPrintCallback rowPrintCallback) { while (property.endsWith("[]")) // cut ending [][] property = property.substring(0, property.length() - 2); List<CellNode> cells = rowNode.getCells(); CellNode cell = cells.get(i);//from www . j av a 2 s .c o m Object value = getPropertyValue(data, property); if (value == null) { cell.changeValue(""); return; } if (value instanceof Number) { cell.changeValue((Number) value); return; } if (value instanceof NativeDate) { value = new Date((long) NativeDate.getTime(value)); } if (value instanceof Date && dateFormat != null) { value = dateFormat.format((Date) value); } value = Utils.tryConvertToJavaCollections(value); if (value instanceof Map) { value = Collections.singletonList(value); } if (value instanceof List) { List list = (List) value; cells.remove(i); if (list.isEmpty()) return; Object mayBeCollection = Utils.tryConvertToJavaCollections(list.get(0)); if (!(mayBeCollection instanceof Map) && !(mayBeCollection instanceof List)) { list = Collections.singletonList(list); // one dimentional array as 2 dimention of one row } for (int l = 0; l < list.size(); l++) { Object line = list.get(l); if (line instanceof Map) line = ((Map) line).values(); line = Utils.tryConvertToJavaCollections(line); if (line instanceof Collection) { Collection lineList = (Collection) line; if (l == 0) { // first line for (int j = 0; j < lineList.size(); j++) { CellNode cc = cell.clone(); cells.add(j + i, cc); cc.changeValue(""); } } int j = 0; for (Iterator iterator = lineList.iterator(); iterator.hasNext(); j++) { Object propertyValue = iterator.next(); CellNode cc = cells.get(i + j); if (propertyValue == null) { propertyValue = ""; } if (propertyValue instanceof Date) { propertyValue = dateFormat.format((Date) value); } if (propertyValue instanceof Number) cc.changeValue((Number) propertyValue); else cc.changeValue(propertyValue.toString()); } if (l < list.size() - 1) rowPrintCallback.printRowNode(rowNode); } } } else { cell.changeValue(value.toString()); } }
From source file:org.bson.jvm.nashorn.NativeDateCodec.java
License:Apache License
public void encode(BsonWriter writer, NativeDate nativeDate, EncoderContext encoderContext) { writer.writeDateTime((long) NativeDate.getTime(nativeDate)); }
From source file:org.siphon.common.js.JsDateUtil.java
License:Open Source License
public long getTime(ScriptObjectMirror nativeDate) { return (long) NativeDate.getTime(((ScriptObjectMirror) nativeDate).to(NativeDate.class)); }
From source file:org.siphon.common.js.JsDateUtil.java
License:Open Source License
public long getTime(NativeDate nativeDate) { return (long) NativeDate.getTime(nativeDate); }
From source file:org.siphon.common.js.JsTypeUtil.java
License:Open Source License
public static long getTime(ScriptObjectMirror nativeDate) { return (long) NativeDate.getTime(((ScriptObjectMirror) nativeDate).to(NativeDate.class)); }
From source file:org.siphon.common.js.JsTypeUtil.java
License:Open Source License
public static long getTime(NativeDate nativeDate) { return (long) NativeDate.getTime(nativeDate); }
From source file:org.siphon.common.js.JsTypeUtil.java
License:Open Source License
private static Object jsObjectToJava(NativeDate arg) { return new Date((long) NativeDate.getTime(arg)); }