C# Class Summer.Batch.Extra.Utils.DateUtils

DateUtils utilitary class.
Mostrar archivo Open project: SummerBatch/SummerBatch

Public Properties

Property Type Description
STANDARD_DATE_FORMAT_WITH_TIRET string

Public Methods

Method Description
AddDaysToCurrentDate ( int days ) : DateTime?

Adds a number of days to the current date.

AddDaysToDate ( System.DateTime date, int days ) : DateTime?

Adds a number of days to a given date.

AddMonthsToCurrentDate ( int months ) : DateTime?

Adds a number of months to the current date.

AddMonthsToDate ( System.DateTime date, int months ) : DateTime?

Adds a number of months to a given date.

AddYearsToCurrentDate ( int years ) : DateTime?

Adds a number of years to the current date.

AddYearsToDate ( System.DateTime date, int years ) : DateTime?

Adds a number of years to a given date.

BuildDate ( int day, int month, int year ) : DateTime?

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

BuildDate ( string day, string month, string year ) : DateTime?

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

CompareDates ( System.DateTime date1, System.DateTime date2 ) : int?

Compares two dates.

CompareDatesIgnoringYear ( System.DateTime date1, System.DateTime date2 ) : int?

Compares two dates ignoring the year.

ConvertDateToString ( System.DateTime date, string pattern ) : string

Converts a date to a string.

ConvertStringToDate ( string sDate ) : DateTime?

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

ConvertStringToDate ( string sDate, string format ) : DateTime?

Convert a string to a date using specified format.

GetDay ( System.DateTime date ) : int?

Retrieves the day of the month of a date.

GetDayAsString ( System.DateTime date ) : string

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

GetDifferenceInDays ( System.DateTime date1, System.DateTime date2 ) : int?

Computes the number of days between two dates.

GetDifferenceInWorkingDays ( System.DateTime date1, System.DateTime date2 ) : int?

Computes the number of working days between two dates.

GetDifferenceInYears ( System.DateTime date1, System.DateTime date2 ) : int?

Computes the number of years between two dates. The first date. The second date. Rounded difference number of years between date2 and date1. Positive if date2>date1, otherwise negative.

GetMonth ( System.DateTime date ) : int?

Retrieves the month of a date.

GetMonthAsString ( System.DateTime date ) : string

Retrieves the month of a date as a string.

GetYear ( System.DateTime date ) : int?

Retrieves the year of a date.

GetYearAsString ( System.DateTime date ) : string

Retrieves the year of a date as a string.

IsInInterval ( System.DateTime dateInf, System.DateTime dateSup, System.DateTime dateToTest ) : bool

Checks if a date is within a time interval.

UpdateYear ( System.DateTime date, int year ) : DateTime?

Updates the year of a date.

UpdateYearAndMonth ( System.DateTime date, int year, int month ) : DateTime?

Updates the year and month of a date.

UpdateYearMonthAndDay ( System.DateTime date, int year, int month, int day ) : DateTime?

Updates the year, month and day of a date. The date to update. The new year. The new month. The new day A new date, with updated year, month and days values.

Private Methods

Method Description
CheckFormatDate ( string sDate, string format ) : DateTime?
CompareDays ( System.DateTime date1, System.DateTime date2 ) : int?
CompareNullDates ( System.DateTime date1, System.DateTime date2 ) : int?

Method Details

AddDaysToCurrentDate() public static method

Adds a number of days to the current date.
public static AddDaysToCurrentDate ( int days ) : DateTime?
days int The number of days to add.
return DateTime?

AddDaysToDate() public static method

Adds a number of days to a given date.
public static AddDaysToDate ( System.DateTime date, int days ) : DateTime?
date System.DateTime The date to modify.
days int The number of days to add.
return DateTime?

AddMonthsToCurrentDate() public static method

Adds a number of months to the current date.
public static AddMonthsToCurrentDate ( int months ) : DateTime?
months int The number of months to add.
return DateTime?

AddMonthsToDate() public static method

Adds a number of months to a given date.
public static AddMonthsToDate ( System.DateTime date, int months ) : DateTime?
date System.DateTime The date to modify.
months int The number of months to add.
return DateTime?

AddYearsToCurrentDate() public static method

Adds a number of years to the current date.
public static AddYearsToCurrentDate ( int years ) : DateTime?
years int The number of years to add.
return DateTime?

AddYearsToDate() public static method

Adds a number of years to a given date.
public static AddYearsToDate ( System.DateTime date, int years ) : DateTime?
date System.DateTime The date to modify.
years int The number of years to add.
return DateTime?

BuildDate() public static method

Builds a date using the given day, month, and year.
public static BuildDate ( int day, int month, int year ) : DateTime?
day int The day of the month.
month int The month.
year int The year.
return DateTime?

BuildDate() public static method

Builds a date using the given day, month, and year.
public static BuildDate ( string day, string month, string year ) : DateTime?
day string The day of the month.
month string The month.
year string The year.
return DateTime?

CompareDates() public static method

Compares two dates.
public static CompareDates ( System.DateTime date1, System.DateTime date2 ) : int?
date1 System.DateTime The first date to compare.
date2 System.DateTime The second date to compare.
return int?

CompareDatesIgnoringYear() public static method

Compares two dates ignoring the year.
public static CompareDatesIgnoringYear ( System.DateTime date1, System.DateTime date2 ) : int?
date1 System.DateTime The first date to compare.
date2 System.DateTime The second date to compare.
return int?

ConvertDateToString() public static method

Converts a date to a string.
public static ConvertDateToString ( System.DateTime date, string pattern ) : string
date System.DateTime The date to convert.
pattern string The date pattern used to parse the date.
return string

ConvertStringToDate() public static method

Converts a string to a date. Supported formats : "ddMMyy", "dd/MM/yyyy", "ddMMyyyy", "dd/MM/yy" and "dd-MM-yyyy".
public static ConvertStringToDate ( string sDate ) : DateTime?
sDate string A string reprensenting a date.
return DateTime?

ConvertStringToDate() public static method

Convert a string to a date using specified format.
public static ConvertStringToDate ( string sDate, string format ) : DateTime?
sDate string A string reprensenting a date.
format string The format to parse the date.
return DateTime?

GetDay() public static method

Retrieves the day of the month of a date.
public static GetDay ( System.DateTime date ) : int?
date System.DateTime A date
return int?

GetDayAsString() public static method

Retrieves the day of the month of a date as a string.
public static GetDayAsString ( System.DateTime date ) : string
date System.DateTime A date
return string

GetDifferenceInDays() public static method

Computes the number of days between two dates.
public static GetDifferenceInDays ( System.DateTime date1, System.DateTime date2 ) : int?
date1 System.DateTime The first date.
date2 System.DateTime The second date.
return int?

GetDifferenceInWorkingDays() public static method

Computes the number of working days between two dates.
public static GetDifferenceInWorkingDays ( System.DateTime date1, System.DateTime date2 ) : int?
date1 System.DateTime The first date.
date2 System.DateTime The second date.
return int?

GetDifferenceInYears() public static method

Computes the number of years between two dates. The first date. The second date. Rounded difference number of years between date2 and date1. Positive if date2>date1, otherwise negative.
public static GetDifferenceInYears ( System.DateTime date1, System.DateTime date2 ) : int?
date1 System.DateTime
date2 System.DateTime
return int?

GetMonth() public static method

Retrieves the month of a date.
public static GetMonth ( System.DateTime date ) : int?
date System.DateTime A date
return int?

GetMonthAsString() public static method

Retrieves the month of a date as a string.
public static GetMonthAsString ( System.DateTime date ) : string
date System.DateTime A date
return string

GetYear() public static method

Retrieves the year of a date.
public static GetYear ( System.DateTime date ) : int?
date System.DateTime A date
return int?

GetYearAsString() public static method

Retrieves the year of a date as a string.
public static GetYearAsString ( System.DateTime date ) : string
date System.DateTime A date
return string

IsInInterval() public static method

Checks if a date is within a time interval.
public static IsInInterval ( System.DateTime dateInf, System.DateTime dateSup, System.DateTime dateToTest ) : bool
dateInf System.DateTime The inferior limit of the time interval.
dateSup System.DateTime The superior limit of the time interval.
dateToTest System.DateTime The date to check.
return bool

UpdateYear() public static method

Updates the year of a date.
public static UpdateYear ( System.DateTime date, int year ) : DateTime?
date System.DateTime The date to update.
year int The new year.
return DateTime?

UpdateYearAndMonth() public static method

Updates the year and month of a date.
public static UpdateYearAndMonth ( System.DateTime date, int year, int month ) : DateTime?
date System.DateTime The date to update.
year int The new year.
month int The new month.
return DateTime?

UpdateYearMonthAndDay() public static method

Updates the year, month and day of a date. The date to update. The new year. The new month. The new day A new date, with updated year, month and days values.
public static UpdateYearMonthAndDay ( System.DateTime date, int year, int month, int day ) : DateTime?
date System.DateTime
year int
month int
day int
return DateTime?

Property Details

STANDARD_DATE_FORMAT_WITH_TIRET public_oe static_oe property

Standard date format with dashes ("dd-MM-yyyy")
public static string STANDARD_DATE_FORMAT_WITH_TIRET
return string