使用Angular和Spring Boot的日期问题

时间:2018-05-15 20:19:47

标签: spring angular date spring-boot momentjs

我使用Angular作为UI,使用SpringBoot作为REST API。在用户界面中收集日期时,日期格式如下:

“2018-05-15T19:00:00.000Z”

在Spring Boot API中录制之后,我刚刚录制的日期就像它一样被检索:

“dataHora”:“2018-05-15T19:00:00.000 + 0000”

问题是,当检索到这种格式时,属性是“未定义的”。我需要做些什么来解决它?对于我而言,我没有粘贴我的代码,因为它可能是一个更通用的问题。

我在Angular中创建了一个类:

export class Rac {
    idRac: number;
    dataHora: Date;
    historico: string;
}

该属性为“dataHora”。我从REST API检索时尝试加载Object:

  carregaRac() {
    this.racService.buscarPorCodigo(this.idRac)
      .then(rac => {
        this.rac = rac;
        this.formulario.patchValue({
          dataHora: this.rac.dataHora,
          historico: this.rac.historico,
        })
         })
      .catch(erro => this.errorHandler.handle(erro));
  }

在上面的这些示例中,当我尝试查看“dataHora”值时,控制台向我显示“未定义”

0 个答案:

没有答案