function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF7SF7 

How can I display month in chinese in apex code?

public with sharing class ScorecardController extends BaseController {

  public Map<String, Map<String, Double>> gradeToUnitsMap {get; private set;}
  public Map<String, Map<String, Double>> applicationToUnitsMap {get; private set;}
  public Map<String, Map<String, Double>> brandToUnitsMap {get; private set;}

  public List<SelectOption> fiscalYearOptions {get; private set;}

  public String selPeriod {get; set;}
  public String selYear {get; set;}

  public List<SelectOption> monthOptions {
    get {
      if ( this.monthOptions == null ) {
        this.monthOptions = new List<SelectOption>{new SelectOption('', System.Label.CCMTY_Month)};
        for ( Integer i = 1; i <= 12; i++ ) {
          DateTime dt = DateTime.newInstance(2015, i, 5);
          this.monthOptions.add(new SelectOption(String.valueOf(i), dt.format('MMMM')));
        }
      }
      return this.monthOptions;
    }
    private set;
  }

  public ScorecardController() {

    // Initialize period variables
    this.selPeriod = '';

    // Default to the previous month
    Integer defaultMonth = System.today().month() - 1;
    // If current month is January, then set month to December
    if ( defaultMonth == 0 ) {
      defaultMonth = 12;
    }
    this.selPeriod = String.valueOf(defaultMonth);

    // Default to current calendar year
    Integer currYear = System.today().year();
    // If default month is Oct or Nov, then increment current calendar year to set correct FY
    // If default month is December, it means that current calendar month is January, and 
    //    there's no need to increment the current calendar year
    if ( defaultMonth > 9 && defaultMonth != 12 ) {
      currYear += 1;
    }
    this.selYear = String.valueOf(currYear);

    this.fiscalYearOptions = 
      CCMTY_Util.getSelectOptionsListByField(Sales_Plan__c.Fiscal_Year__c, null);

    doCalculations();
  }