code: public static Timestamp toTimestamp(DateTime dt) {
          if (dt == null) {
              return null;
          } else {
              return new Timestamp(dt.getMillis());
          }
      }
docs: Null-safe method of converting a DateTime to a Timestamp.
  <br>
  NOTE: The timestamp also should be in UTC.
  @return A UTC DateTime