Skip to content

Instantly share code, notes, and snippets.

@randi274
Created November 23, 2020 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randi274/50558ca02cbf6c89acecfbe21f602204 to your computer and use it in GitHub Desktop.
Save randi274/50558ca02cbf6c89acecfbe21f602204 to your computer and use it in GitHub Desktop.
DateTimeProvider - Class using the Singleton Pattern
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