public static function format($value, $to, $from = null)
    {
        if ($to instanceof Measure === false) {
            throw new Exception('Unknown object');
        }
        if ($from instanceof Measure) {
            $value = static::convert($value, $to, $from);
        }
        $formatter = $to->use_custom_formatter == true ? $to->formatter : \Yii::$app->formatter;
        return strtr(
            $to->format,
            [
                '#' => $formatter->asDecimal($value),
                '$' => static::t($to->unit),
            ]
        );
    }