MangoCode
MangoCode

Reputation: 38

Month number to month names

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. Is there a way in MongoDB?
  2. Or is it suggested Do the mapping to json data?

Upvotes: 0

Views: 985

Answers (1)

Rotem
Rotem

Reputation: 1379

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

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

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.

Upvotes: 1

Related Questions