Skip to main content

Posts

Showing posts with the label current String value of Month in Salesforce

Important Apex Code for getting Months, Days and Years:

Important Apex Code for getting Months, Days and Years: system.now().formatGMT('MMMMMMMMMMM') :  This line will return Current Month in string up to 11 Character. Fix the number of character by changing number of 'M'. if system date is somewhere in the month of January then : string monthName = system.now().formatGMT('MMM'); //return JAN DateTime.newInstanceGMT(Date.newInstance(2000, monthCount, 1), Time.newInstance(0, 0, 0, 0)).formatGMT('MMM') : This will return Month in string based on integer value ' monthCount ' , (1=JAN, 2=FEB...) Number of 'M' will decide how many character value should be return. Note : Use M for Month, D for day(days of year), Y for year.

Translate