Created
September 4, 2015 15:57
-
-
Save maxdemarzi/5486da54417dcf8f1ca0 to your computer and use it in GitHub Desktop.
string to millis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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