• 请不要在回答技术问题时复制粘贴 AI 生成的内容
NoKey
V2EX  ›  程序员

如何批量转换数据库得到的日期格式

  •  
  •   NoKey · Feb 12, 2021 · 1963 views
    This topic created in 2089 days ago, the information mentioned may be changed or developed.

    我目前用的 jpa+postgresql

    在 pg 里面时间字段的类型是 timesatamp

    查出来用 date 类型字段接受

    默认的格式不是年月日时分秒,需要转换一次

    这个有没有啥比较好的转换手段啊

    不能说查 1 万条出来,每一条我需要转换一次吧。。。

    请大佬赐教,谢谢

    5 replies  •  2021-03-04 23:48:12 +08:00
    chendy
    chendy
    Feb 13, 2021
    1
    你的场景是什么?接口返回数据?导出数据?
    无论哪种,在出口或者需要的地方 format 就行,一万条就一万次喽,又不慢~
    yungo8
    yungo8
    Feb 13, 2021 via Android
    2
    那你先写 sql 转字符串用字符串类型接收不行吗?
    carity
    carity
    Feb 13, 2021
    3
    十万条不也是秒秒钟?
    unbright
    unbright
    Feb 20, 2021
    4
    有个 @Convert 的注解
    NoKey
    NoKey
    OP
    Mar 4, 2021
    5
    @unbright 感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1403 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:07 · PVG 06:07 · LAX 14:07 · JFK 17:07
    ♥ Do have faith in what you're doing.