• Matthew Bathersby
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have a simple controller that is designed to act as a time. As so:

public class timerController {

    public static dateTime startTime {get;set;}
    public static dateTime stopTime {get;set;}
 
    public static void startTimer(){

        startTime = system.now();

        system.debug(startTime);
    }
    
    public static void stopTimer(){
        
        stopTime = system.now();

        system.debug(startTime);
        system.debug(stopTime);
    }

}

Each method is tied to a button ('Start Timer' and 'Stop Timer'). When I run the startTimer method, I can see the startTime value in my debug.
When I run the stopTimer method, I can see the stopTime value in my debug, but the startTime has been reset to null.

Why is the startTime value not being maintained in the state? I know I must be missing something small, but I can't for the life of me spot it.

Any suggestions would be greatly appreciated.

I have a simple controller that is designed to act as a time. As so:

public class timerController {

    public static dateTime startTime {get;set;}
    public static dateTime stopTime {get;set;}
 
    public static void startTimer(){

        startTime = system.now();

        system.debug(startTime);
    }
    
    public static void stopTimer(){
        
        stopTime = system.now();

        system.debug(startTime);
        system.debug(stopTime);
    }

}

Each method is tied to a button ('Start Timer' and 'Stop Timer'). When I run the startTimer method, I can see the startTime value in my debug.
When I run the stopTimer method, I can see the stopTime value in my debug, but the startTime has been reset to null.

Why is the startTime value not being maintained in the state? I know I must be missing something small, but I can't for the life of me spot it.

Any suggestions would be greatly appreciated.