AJN
AJN

Reputation: 1206

Does neo4j supports property data format?

Does neo4j natively support data format for node properties? like for example url links (clickable), numbers (integer, float..), date (YYYY/MM/DD).

Or we need to programmatically convert property string to whatever format we need?

Upvotes: 2

Views: 858

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

Property values in Neo4j could be either Java primitive types (float, double, int, boolean, byte,... ), Strings or array of both. Date objects as property values are not supported.

There are two ways to deal with days:

  1. Store the date as msec since epoc, aka new Date().getTime() (in java)

    • pro: you can do calculations
    • pro: less memory/disc consumption as it's stored as a long
    • con: when just looking at the node, it's hard to infer the date without calculation
  2. Store the date as a string using e.g. SimpleDateFormatter

    • pro: human readable
    • con: calculations are hard

Personally I tend to prefer the first one.

In case you need to store time + timezone, you can have two properties. One for the date in msecs based on UTC, another one for the timezone.

Upvotes: 4

Related Questions