Summer.Batch.Extra.Utils.DateUtils Class Reference

DateUtils utilitary class. More...

Static Public Member Functions

static string ConvertDateToString (DateTime?date, string pattern)
 Converts a date to a string. More...
 
static DateTime BuildDate (int?day, int?month, int?year)
 Builds a date using the given day, month, and year. More...
 
static DateTime BuildDate (string day, string month, string year)
 Builds a date using the given day, month, and year. More...
 
static DateTime UpdateYear (DateTime?date, int?year)
 Updates the year of a date. More...
 
static DateTime UpdateYearAndMonth (DateTime?date, int?year, int?month)
 Updates the year and month of a date. More...
 
static DateTime UpdateYearMonthAndDay (DateTime?date, int?year, int?month, int?day)
 Updates the year, month and day of a date.

Parameters
dateThe date to update.
yearThe new year.
monthThe new month.
dayThe new day
Returns
A new date, with updated year, month and days values.
More...
 
static DateTime AddDaysToCurrentDate (int?days)
 Adds a number of days to the current date. More...
 
static DateTime AddMonthsToCurrentDate (int?months)
 Adds a number of months to the current date. More...
 
static DateTime AddYearsToCurrentDate (int?years)
 Adds a number of years to the current date. More...
 
static DateTime AddDaysToDate (DateTime?date, int?days)
 Adds a number of days to a given date. More...
 
static DateTime AddMonthsToDate (DateTime?date, int?months)
 Adds a number of months to a given date. More...
 
static DateTime AddYearsToDate (DateTime?date, int?years)
 Adds a number of years to a given date. More...
 
static int CompareDates (DateTime?date1, DateTime?date2)
 Compares two dates. More...
 
static int CompareDatesIgnoringYear (DateTime?date1, DateTime?date2)
 Compares two dates ignoring the year. More...
 
static bool IsInInterval (DateTime?dateInf, DateTime?dateSup, DateTime?dateToTest)
 Checks if a date is within a time interval. More...
 
static int GetDifferenceInDays (DateTime?date1, DateTime?date2)
 Computes the number of days between two dates. More...
 
static int GetDifferenceInYears (DateTime?date1, DateTime?date2)
 Computes the number of years between two dates.

Parameters
date1The first date.
date2The second date.
Returns
Rounded difference number of years between date2 and date1. Positive if date2>date1, otherwise negative.
More...
 
static int GetDifferenceInWorkingDays (DateTime?date1, DateTime?date2)
 Computes the number of working days between two dates. More...
 
static int GetYear (DateTime?date)
 Retrieves the year of a date. More...
 
static string GetYearAsString (DateTime?date)
 Retrieves the year of a date as a string. More...
 
static int GetMonth (DateTime?date)
 Retrieves the month of a date. More...
 
static string GetMonthAsString (DateTime?date)
 Retrieves the month of a date as a string. More...
 
static int GetDay (DateTime?date)
 Retrieves the day of the month of a date. More...
 
static string GetDayAsString (DateTime?date)
 Retrieves the day of the month of a date as a string. More...
 
static DateTime ConvertStringToDate (string sDate)
 Converts a string to a date. Supported formats : "ddMMyy", "dd/MM/yyyy", "ddMMyyyy", "dd/MM/yy" and "dd-MM-yyyy". More...
 
static DateTime ConvertStringToDate (string sDate, string format)
 Convert a string to a date using specified format. More...
 

Public Attributes

const long MILLISECOND_PER_DAY = 24 * 60 * 60 * 1000
 Number of millisenconds in a day. More...
 
const long MILLISECOND_PER_YEAR = MILLISECOND_PER_DAY * 365
 Number of millisenconds in a year. More...
 
const string SHORT_DATE_FORMAT = "ddMMyy"
 Short date format ("ddMMyy"). More...
 
const string STANDARD_DATE_FORMAT = "dd/MM/yyyy"
 Standard date format ("dd/MM/yyyy") More...
 
const string STANDARD_DATE_FORMAT_WITHOUT_SEP = "ddMMyyyy"
 Standard date format, without separators ("ddMMyyyy") More...
 
const string SHORT_DATE_FORMAT_WITH_SEP = "dd/MM/yy"
 Short date format, with separators ("ddMMyy") More...
 

Static Public Attributes

static readonly string STANDARD_DATE_FORMAT_WITH_TIRET = "dd-MM-yyyy"
 Standard date format with dashes ("dd-MM-yyyy") More...
 

Detailed Description

DateUtils utilitary class.

Member Function Documentation

static DateTime Summer.Batch.Extra.Utils.DateUtils.AddDaysToCurrentDate ( int?  days)
static

Adds a number of days to the current date.

Parameters
daysThe number of days to add.
Returns
A new date, built by adding days days to the current date.
static DateTime Summer.Batch.Extra.Utils.DateUtils.AddDaysToDate ( DateTime?  date,
int?  days 
)
static

Adds a number of days to a given date.

Parameters
dateThe date to modify.
daysThe number of days to add.
Returns
A new date, built by adding days days to the date .
static DateTime Summer.Batch.Extra.Utils.DateUtils.AddMonthsToCurrentDate ( int?  months)
static

Adds a number of months to the current date.

Parameters
monthsThe number of months to add.
Returns
A new date, built by adding months months to the current date.
static DateTime Summer.Batch.Extra.Utils.DateUtils.AddMonthsToDate ( DateTime?  date,
int?  months 
)
static

Adds a number of months to a given date.

Parameters
dateThe date to modify.
monthsThe number of months to add.
Returns
A new date, built by adding months months to the date .
static DateTime Summer.Batch.Extra.Utils.DateUtils.AddYearsToCurrentDate ( int?  years)
static

Adds a number of years to the current date.

Parameters
yearsThe number of years to add.
Returns
A new date, built by adding years years to the current date.
static DateTime Summer.Batch.Extra.Utils.DateUtils.AddYearsToDate ( DateTime?  date,
int?  years 
)
static

Adds a number of years to a given date.

Parameters
dateThe date to modify.
yearsThe number of years to add.
Returns
A new date, built by adding years years to the date .
static DateTime Summer.Batch.Extra.Utils.DateUtils.BuildDate ( int?  day,
int?  month,
int?  year 
)
static

Builds a date using the given day, month, and year.

Parameters
dayThe day of the month.
monthThe month.
yearThe year.
Returns
A new instance of DateTime.
static DateTime Summer.Batch.Extra.Utils.DateUtils.BuildDate ( string  day,
string  month,
string  year 
)
static

Builds a date using the given day, month, and year.

Parameters
dayThe day of the month.
monthThe month.
yearThe year.
Returns
A new instance of DateTime.
static int Summer.Batch.Extra.Utils.DateUtils.CompareDates ( DateTime?  date1,
DateTime?  date2 
)
static

Compares two dates.

Parameters
date1The first date to compare.
date2The second date to compare.
Returns
1 if the first date is later than the second date. -1 If the first date is anterior to the second date, 0 if the two dates are identical (to the day).
static int Summer.Batch.Extra.Utils.DateUtils.CompareDatesIgnoringYear ( DateTime?  date1,
DateTime?  date2 
)
static

Compares two dates ignoring the year.

Parameters
date1The first date to compare.
date2The second date to compare.
Returns
-1 If the first date is anterior to the second date, 0 if the two dates are identical (to the day).
static string Summer.Batch.Extra.Utils.DateUtils.ConvertDateToString ( DateTime?  date,
string  pattern 
)
static

Converts a date to a string.

Parameters
dateThe date to convert.
patternThe date pattern used to parse the date.
Returns
String representation of given date.
static DateTime Summer.Batch.Extra.Utils.DateUtils.ConvertStringToDate ( string  sDate)
static

Converts a string to a date. Supported formats : "ddMMyy", "dd/MM/yyyy", "ddMMyyyy", "dd/MM/yy" and "dd-MM-yyyy".

Parameters
sDateA string reprensenting a date.
Returns
The date extracted from sDate .
static DateTime Summer.Batch.Extra.Utils.DateUtils.ConvertStringToDate ( string  sDate,
string  format 
)
static

Convert a string to a date using specified format.

Parameters
sDateA string reprensenting a date.
formatThe format to parse the date.
Returns
The date extracted from sDate .
static int Summer.Batch.Extra.Utils.DateUtils.GetDay ( DateTime?  date)
static

Retrieves the day of the month of a date.

Parameters
dateA date
Returns
The day of the month of given date.
static string Summer.Batch.Extra.Utils.DateUtils.GetDayAsString ( DateTime?  date)
static

Retrieves the day of the month of a date as a string.

Parameters
dateA date
Returns
The string representation of the day of the month of given date.
static int Summer.Batch.Extra.Utils.DateUtils.GetDifferenceInDays ( DateTime?  date1,
DateTime?  date2 
)
static

Computes the number of days between two dates.

Parameters
date1The first date.
date2The second date.
Returns
Rounded difference number of days between date2 and date1. Positive if date2>date1, otherwise negative.
static int Summer.Batch.Extra.Utils.DateUtils.GetDifferenceInWorkingDays ( DateTime?  date1,
DateTime?  date2 
)
static

Computes the number of working days between two dates.

Parameters
date1The first date.
date2The second date.
Returns
Rounded difference number of working days between date2 and date1. Positive if date2>date1, otherwise negative.
static int Summer.Batch.Extra.Utils.DateUtils.GetDifferenceInYears ( DateTime?  date1,
DateTime?  date2 
)
static

Computes the number of years between two dates.

Parameters
date1The first date.
date2The second date.
Returns
Rounded difference number of years between date2 and date1. Positive if date2>date1, otherwise negative.

static int Summer.Batch.Extra.Utils.DateUtils.GetMonth ( DateTime?  date)
static

Retrieves the month of a date.

Parameters
dateA date
Returns
The month of given date.
static string Summer.Batch.Extra.Utils.DateUtils.GetMonthAsString ( DateTime?  date)
static

Retrieves the month of a date as a string.

Parameters
dateA date
Returns
The string representation of the month of given date.
static int Summer.Batch.Extra.Utils.DateUtils.GetYear ( DateTime?  date)
static

Retrieves the year of a date.

Parameters
dateA date
Returns
The year of given date.
static string Summer.Batch.Extra.Utils.DateUtils.GetYearAsString ( DateTime?  date)
static

Retrieves the year of a date as a string.

Parameters
dateA date
Returns
The string representation of the year of given date.
static bool Summer.Batch.Extra.Utils.DateUtils.IsInInterval ( DateTime?  dateInf,
DateTime?  dateSup,
DateTime?  dateToTest 
)
static

Checks if a date is within a time interval.

Parameters
dateInfThe inferior limit of the time interval.
dateSupThe superior limit of the time interval.
dateToTestThe date to check.
Returns
true if dateToTest is included between dateInf and dateSup .
static DateTime Summer.Batch.Extra.Utils.DateUtils.UpdateYear ( DateTime?  date,
int?  year 
)
static

Updates the year of a date.

Parameters
dateThe date to update.
yearThe new year.
Returns
A new date, with updated year value.
static DateTime Summer.Batch.Extra.Utils.DateUtils.UpdateYearAndMonth ( DateTime?  date,
int?  year,
int?  month 
)
static

Updates the year and month of a date.

Parameters
dateThe date to update.
yearThe new year.
monthThe new month.
Returns
A new date, with updated year and month values.
static DateTime Summer.Batch.Extra.Utils.DateUtils.UpdateYearMonthAndDay ( DateTime?  date,
int?  year,
int?  month,
int?  day 
)
static

Updates the year, month and day of a date.

Parameters
dateThe date to update.
yearThe new year.
monthThe new month.
dayThe new day
Returns
A new date, with updated year, month and days values.

Member Data Documentation

const long Summer.Batch.Extra.Utils.DateUtils.MILLISECOND_PER_DAY = 24 * 60 * 60 * 1000

Number of millisenconds in a day.

const long Summer.Batch.Extra.Utils.DateUtils.MILLISECOND_PER_YEAR = MILLISECOND_PER_DAY * 365

Number of millisenconds in a year.

const string Summer.Batch.Extra.Utils.DateUtils.SHORT_DATE_FORMAT = "ddMMyy"

Short date format ("ddMMyy").

const string Summer.Batch.Extra.Utils.DateUtils.SHORT_DATE_FORMAT_WITH_SEP = "dd/MM/yy"

Short date format, with separators ("ddMMyy")

const string Summer.Batch.Extra.Utils.DateUtils.STANDARD_DATE_FORMAT = "dd/MM/yyyy"

Standard date format ("dd/MM/yyyy")

readonly string Summer.Batch.Extra.Utils.DateUtils.STANDARD_DATE_FORMAT_WITH_TIRET = "dd-MM-yyyy"
static

Standard date format with dashes ("dd-MM-yyyy")

const string Summer.Batch.Extra.Utils.DateUtils.STANDARD_DATE_FORMAT_WITHOUT_SEP = "ddMMyyyy"

Standard date format, without separators ("ddMMyyyy")


The documentation for this class was generated from the following file:
  • Summer.Batch.Extra/Utils/DateUtils.cs