I am using the Joda-Time library in Java, and have a date and time stored as an org.joda.time.DateTime object.
How can I reliably convert this DateTime object into a
I use this simple function to get a SQL-friendly date format from a JodaTime DateTime
object:
// Converts a DateTime object into a SQL-format friendly string.
//
// Return format looks like this: 2014-01-22 10:05:34.546
//
public static String toSql(DateTime dateTime) {
return new Timestamp( dateTime.getMillis() ).toString();
}