MVC5 TextboxFor dispay Date without Time

时间:2017-06-05 07:46:16

标签: jquery asp.net-mvc html-table

我试图只在没有时间的情况下显示日期,但似乎没有任何东西可以用于MVC5。我需要使用TextboxFor而不是EditorFor。我试过了:

DriveService.Scope.DriveFile, DriveService.Scope.Drive

它仍然显示时间。

 <td class="input-pricing">@Html.TextBoxFor(m => new ProjectPricing().UnitTypePriceEffDate,"{0:MM/dd/yy}", new {id = "model-effectiveDate", @class = "date" })</td>

我在jQuery中克隆模型:

UnitTypePriceEffDate is of DateTimeOffSet type.

有人可以帮忙吗?谢谢!

1 个答案:

答案 0 :(得分:1)

尝试以下(我假设UnitTypePriceEffDate是DateTime类型):

class Loan {
    private Loan() {
    }

    public Loan doSomething(int m) {
        System.out.println("Did something " + m);
        if (new Random().nextBoolean()) {
            throw new RuntimeException("Didn't see that commming");
        }
        return this;
    }

    public Loan doOtherThing(int n) {
        System.out.println("Did other thing " + n);
        return this;
    }

    private void close() {
        System.out.println("Closed");
    }

    public static void loan(Consumer<Loan> toPerform) {
        Loan loan = new Loan();
        try {
            toPerform.accept(loan);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            loan.close();
        }
    }
}