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

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

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