Skip to content

Instantly share code, notes, and snippets.

@maxdemarzi
Created September 4, 2015 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxdemarzi/5486da54417dcf8f1ca0 to your computer and use it in GitHub Desktop.
Save maxdemarzi/5486da54417dcf8f1ca0 to your computer and use it in GitHub Desktop.
string to millis
private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int i = 0;
Transaction tx = db.beginTx();
try {
for ( Node node : GlobalGraphOperations.at(db).getAllNodes()) {
Date theDate = DATE_FORMAT.parse((String)node.getProperty("my_date_as_string_property", "2099-12-31 12:00:00"));
node.setProperty("new_date_as_millis", theDate.getTime());
i++;
// Commit every x transactions
if (i % 10000 == 0) {
tx.success();
tx.close();
tx = db.beginTx();
}
}
tx.success();
} finally {
tx.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment