Using Native Date and Time for GLV Time Data - Amazon Neptune
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using Native Date and Time for GLV Time Data

If you are using a Gremlin Language Variant (GLV), you must use the native date and time classes and functions provided by the programming language for Gremlin time data.

The official TinkerPop Java, Node.js (JavaScript), Python, or .NET libraries are all Gremlin Language Variant libraries.

Important

This only applies to Gremlin Language Variant (GLV) libraries. If you are using a method where you send the Gremlin query as text string, you must use the datetime() method provided by Neptune. This includes the Gremlin Console, text strings using the HTTP REST API, and any other serialization that uses Groovy. For more information, see the preceding section, Using the datetime( ) Method for Groovy Time Data.

Python

The following is a partial example in Python that creates a single property named 'date' for the vertex with an ID of '3'. It sets the value to be a date generated using the Python datetime.now() method.

import datetime g.V('3').property('date',datetime.datetime.now()).next()

For a complete example for connecting to Neptune using Python, see Using Python to connect to a Neptune DB instance

Node.js (JavaScript)

The following is a partial example in JavaScript that creates a single property named 'date' for the vertex with an ID of '3'. It sets the value to be a date generated using the Node.js Date() constructor.

g.V('3').property('date', new Date()).next()

For a complete example for connecting to Neptune using Node.js, see Using Node.js to connect to a Neptune DB instance

Java

The following is a partial example in Java that creates a single property named 'date' for the vertex with an ID of '3'. It sets the value to be a date generated using the Java Date() constructor.

import java.util.date g.V('3').property('date', new Date()).next();

For a complete example for connecting to Neptune using Java, see Using a Java client to connect to a Neptune DB instance

.NET (C#)

The following is a partial example in C# that creates a single property named 'date' for the vertex with an ID of '3'. It sets the value to be a date generated using the .NET DateTime.UtcNow property.

Using System; g.V('3').property('date', DateTime.UtcNow).next()

For a complete example for connecting to Neptune using C#, see Using .NET to connect to a Neptune DB instance