We have a method we use to pass in an Integer and convert it to a string version of the year we want:

public static String translateYear(Integer numYrsRequested) {
   return String.Valueof(Date.Today().Year() - numYrsRequested);
  • 0 = Current Year
  • 1 = Last Year
  • 2 = Two Years Ago (etc.)

Its late and I don't quite know how I would reverse this but need to. Any one got a quick solution?

public static Integer reverseTranslateYear(String year){
   return Date.Today().Year() - Integer.ValueOf(year); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.