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
Anuja Joshi 16Anuja Joshi 16 

Error Error: Compile Error: unexpected token: ')' at line 25 column 40

Hello
        I am new in Salesforce .I created VF page controller class.In that I got the month year and want to convert month which is in Number format into string so for this I wrote the method Getmonth() but having error.Please help.
public class UploadCSVFileController
{
    private final Account acct;
    public id accountid{get;set;}
    public string Mon{get;set;}
    public string Yrs{get;set;}
    Public Period__c cp;
    Public String Monthinletter;
    Public String MonthWithZero;
    public UploadCSVFileController(apexpages.standardcontroller stdcontroller)
    {
        system.debug('Inside Constructor');
        acct=(Account)stdcontroller.getrecord();
        accountid=acct.id;
        System.debug('The account id'+accountid);
        Mon = ApexPages.currentPage().getParameters().get('mm');
        Yrs = ApexPages.currentPage().getParameters().get('yyyy');
        System.debug('The current month is:'+Mon);
        System.debug('The current year is:'+Yrs);   
        MonthWithZero=Mon.leftpad(2,'0');
        string monthyear=MonthWithZero+'-'+yrs;
        cp=[select id,name,Month_Year__c from Period__c WHERE name=:monthyear];
        system.debug(cp);
    }
    public String GetMonth(MonthWithZero)
    {
        if(MonthWithZero=='01')
        {
            Monthinletter='January';
            return Monthinletter;    
        }    
    }
}
Martijn SchwarzerMartijn Schwarzer
Hi Anuja,

I see no missing or extra "(" or ")" characters, but  I do see one issue:

In the following line of code, the datatype is missing:
 
public String GetMonth(MonthWithZero)

should actually be something like:
 
public String GetMonth(Integer MonthWithZero)

Hope this helps!

Best regards,
Martijn Schwärzer

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Anuja Joshi 16Anuja Joshi 16
Hello Thanks for your reply but still it not work.
Head In CloudHead In Cloud
Hi Anuja,

Change this line :
public String GetMonth(MonthWithZero)

To this line:
public String GetMonth(String MonthWithZero)

This will solve the issue.
Please mark as best answer if it helps. Thanks