月份编号到月份名称 [英] Month number to month names

查看:59
本文介绍了月份编号到月份名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能已经得到回答,但我就是找不到,对于 MongoDB 中返回的值,将月份数字转换为月份名称的建议方法是什么.

This may have been answered but I just couldn't find it, what is the suggested way to convert a month number to month name for a value returned in MongoDB.

  1. MongoDB 中有没有办法?
  2. 或者是否建议映射到json数据?

推荐答案

最好的方法是创建 ENUM 类支持 映射.

The best way is to create ENUM class supports that mapping.

public enum Month {
    JANUARY, FEBRUARY, MARCH, APRIL; //...
}

这应该不是 MongoDB 的问题.对数据库的调用成本很高,而且您不想在简单的常量数据上花费时间.

It should not be an issue of the MongoDB. The calls to the database are expensive and you do not want to spend time on simple constants data.

这篇关于月份编号到月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆