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

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

  •  
  •   NoKey · Feb 12, 2021 · 1970 views
    This topic created in 2093 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   ·   2112 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 03:28 · PVG 11:28 · LAX 19:28 · JFK 22:28
    ♥ Do have faith in what you're doing.