-
-
Save randi274/50558ca02cbf6c89acecfbe21f602204 to your computer and use it in GitHub Desktop.
DateTimeProvider - Class using the Singleton Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual with sharing class DateTimeProvider { | |
@TestVisible | |
private static DateTimeProvider instance; | |
public static DateTimeProvider getInstance() { | |
if (instance == null) { | |
instance = new DateTimeProvider(); | |
} | |
return instance; | |
} | |
protected DateTimeProvider() {} | |
public virtual DateTime now() { | |
return DateTime.now(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment