Skip to content

scottbcovert/apex-dateservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apex DateService

This utility class was built to provide the same date literal values that Salesforce built for SOQL queries in generic Apex.

The class supports all date literals found in the old documentation (screnshots below), which includes all those in the new documentation as well as a few others. In addition, I've added support for half years, fiscal half years, & N [Period Type]S FROM NOW.

DateLiterals

DateLiterals2

DateLiterals3

The boundaries returned by DateService are an inclusive representation of given date literals and can be used like so:

Map<String,DateTime> tomorrowBoundaryByDateTime = DateService.dateLiteralToDateTimeMap(DateLiteral.TOMORROW);
DateTime lastTwoMonthsStartBoundary = DateService.dateLiteralToStartDateTime(DateLiteral.LAST_N_MONTHS,2);
Date endSevenFiscalYearsBoundary = DateService.dateLiteralToEndDate(DateLiteral.NEXT_N_FISCAL_YEARS,7);
System.assertEquals( endSevenFiscalYearsBoundary, DateService.dateLiteralToDateMap(DateLiteral.NEXT_N_FISCAL_YEARS,7).get(DateService.END_KEY) );

Documentation was created using ApexDocs (originally developed by Aslam Bari and later improved by Steve Cox) and has been included in the project

Happy Coding!

About

Provides Date Services for Apex

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages