Search in sources :

Example 16 with MySQLTime

use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.

the class MySQLcom method getDateFromStr.

/**
 * @return converted value. 0 on error and on zero-dates -- check 'failure'
 * @brief Convert date provided in a string to its packed temporal int
 * representation.
 * @param[in] thd thread handle
 * @param[in] str a string to convert
 * @param[in] warn_type type of the timestamp for issuing the warning
 * @param[in] warn_name field name for issuing the warning
 * @param[out] error_arg could not extract a DATE or DATETIME
 * @details Convert date provided in the string str to the int
 * representation. If the string contains wrong date or doesn't
 * contain it at all then a warning is issued. The warn_type and
 * the warn_name arguments are used as the name and the type of the
 * field when issuing the warning.
 */
public static long getDateFromStr(String str, MySQLTimestampType warntype, BoolPtr error) {
    MySQLTime ltime = new MySQLTime();
    MySQLTimeStatus status = new MySQLTimeStatus();
    error.set(MyTime.strToDatetime(str, str.length(), ltime, MyTime.TIME_FUZZY_DATE, status));
    if (error.get())
        return 0;
    return MyTime.timeToLonglongDatetimePacked(ltime);
}
Also used : MySQLTime(com.actiontech.dble.plan.common.time.MySQLTime) MySQLTimeStatus(com.actiontech.dble.plan.common.time.MySQLTimeStatus)

Aggregations

MySQLTime (com.actiontech.dble.plan.common.time.MySQLTime)16 LongPtr (com.actiontech.dble.plan.common.ptr.LongPtr)6 StringPtr (com.actiontech.dble.plan.common.ptr.StringPtr)1 DateTimeFormat (com.actiontech.dble.plan.common.time.DateTimeFormat)1 MySQLTimeStatus (com.actiontech.dble.plan.common.time.MySQLTimeStatus)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1