Class DateFormatter
This class convert date time formats and return as a string.
Inheritance
Inherited Members
Namespace: SDBCS.utility
Assembly: SDBCS.dll
Syntax
public class DateFormatterRemarks
Author Mehmet Hayati KINAŞ
Version 1.0
Constructors
DateFormatter()
The constructor call initialize method.
Declaration
public DateFormatter()DateFormatter(Int32)
The constructor call initialize method, set dbSystem.
Declaration
public DateFormatter(int dbSystem)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | dbSystem | DB system selector as integer. | 
DateFormatter(Int32, Int32, Int32, Int32, Int32, Boolean, Boolean)
The constructor sets dbSystem, brackets, dateFormat, hourFormat, sqlDF, isSimple, isForm for formatting date time and call initDF method.
Declaration
public DateFormatter(int dbSystem, int brackets, int dateFormat, int hourFormat, int sqlDF, bool isSimple, bool isForm)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | dbSystem | DB system selector as integer. | 
| System.Int32 | brackets | Brackets selector as integer. | 
| System.Int32 | dateFormat | Date format selector as integer. | 
| System.Int32 | hourFormat | Hour format selector as integer. | 
| System.Int32 | sqlDF | SQL server date time format selector as integer. | 
| System.Boolean | isSimple | If it is simple format type set true, else set false. | 
| System.Boolean | isForm | If it is form type set true, else set false. | 
Fields
ANSI_DATE
ANSI format 102
Declaration
public const int ANSI_DATE = 102Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
BF_DATE
Biritish French 103
Declaration
public const int BF_DATE = 103Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
DASH
DASH = 2
Declaration
public const int DASH = 2Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
DB2
DB2 RDBMS
Declaration
public const int DB2 = 4Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
DEF_PMS
Default 109
Declaration
public const int DEF_PMS = 109Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
DMY
DayMonthYear DMY = 0
Declaration
public const int DMY = 0Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
HHMMSS
HHMMSS 108
Declaration
public const int HHMMSS = 108Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
HM
HourMinute HM = 1
Declaration
public const int HM = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
HMSM
HMSM 114
Declaration
public const int HMSM = 114Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
MDY
MonthDayYear MDY = 1
Declaration
public const int MDY = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
MYSQL
MySQL RDBMS
Declaration
public const int MYSQL = 0Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
NO
NO = 0
Declaration
public const int NO = 0Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
ORACLE
Oracle RDBMS
Declaration
public const int ORACLE = 2Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
POINT
POINT = 0
Declaration
public const int POINT = 0Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
POSTGRESQL
Postgresql RDBMS
Declaration
public const int POSTGRESQL = 3Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
SLASH
SLASH = 1
Declaration
public const int SLASH = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
SPACE
SPACE = 3
Declaration
public const int SPACE = 3Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
SQLSERVER
SQL Server RDBMS
Declaration
public const int SQLSERVER = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
SQV1
SQV1 = 0
Declaration
public const int SQV1 = 0Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
SQV2
SQV2 = 1
Declaration
public const int SQV2 = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
T
HourMinuteSecond T = 2
Declaration
public const int T = 2Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
TMSTMP
TimeStamp 120
Declaration
public const int TMSTMP = 120Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
TURK_DATE
Turkish (German) format 104
Declaration
public const int TURK_DATE = 104Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
US_DATE
U.S. format 101
Declaration
public const int US_DATE = 101Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
YMD
YearMonthDay YMD = 2
Declaration
public const int YMD = 2Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
Properties
cultureInfo
For localizing
Declaration
public CultureInfo cultureInfo { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Globalization.CultureInfo | 
Methods
changeDateFormat(String)
For changing date string format from source to target format and return date string value. Use default source and target formats.
Declaration
public string changeDateFormat(string dateStr)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | dateStr | Date as a string | 
Returns
| Type | Description | 
|---|---|
| System.String | Date string value | 
changeDateFormat(String, String, String)
For changing date string format from source to target format and return date string value.
Declaration
public string changeDateFormat(string dateStr, string sourceDF, string targetDF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | dateStr | Date as a string | 
| System.String | sourceDF | DatehourFormatter instance for source format | 
| System.String | targetDF | DatehourFormatter instance for target format | 
Returns
| Type | Description | 
|---|---|
| System.String | Date string value | 
changeDateFrmtforForm(Boolean)
Firstly save default date time format and set form date time format as default. If it is not first set saved format to default.
Declaration
public void changeDateFrmtforForm(bool isFirst)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | isFirst | If it is first time usage set true, else set false. | 
getBrackets()
For getting brackets
Declaration
public int getBrackets()Returns
| Type | Description | 
|---|---|
| System.Int32 | brackets | 
getDateFormat()
For getting dateFormat
Declaration
public int getDateFormat()Returns
| Type | Description | 
|---|---|
| System.Int32 | dateFormat | 
getDbSystem()
For getting dbSystem
Declaration
public int getDbSystem()Returns
| Type | Description | 
|---|---|
| System.Int32 | dbSystem | 
getFormBrk()
For getting formBrk
Declaration
public int getFormBrk()Returns
| Type | Description | 
|---|---|
| System.Int32 | formBrk | 
getFormDF()
For getting string form date format
Declaration
public string getFormDF()Returns
| Type | Description | 
|---|---|
| System.String | If hourFormat is MDY return "MDY" or if is what else. | 
getFormHF()
For getting string form hour format
Declaration
public string getFormHF()Returns
| Type | Description | 
|---|---|
| System.String | If hourFormat is HM return "HM" or if is what else. | 
getHourFormat()
For getting hourFormat
Declaration
public int getHourFormat()Returns
| Type | Description | 
|---|---|
| System.Int32 | hourFormat | 
getIsCast()
For getting isCast
Declaration
public bool getIsCast()Returns
| Type | Description | 
|---|---|
| System.Boolean | isCast | 
getIsForm()
For setting isForm
Declaration
public bool getIsForm()Returns
| Type | Description | 
|---|---|
| System.Boolean | isForm | 
getIsSimple()
For getting isSimple
Declaration
public bool getIsSimple()Returns
| Type | Description | 
|---|---|
| System.Boolean | isSimple | 
getSourceDF()
For getting sourceDF
Declaration
public string getSourceDF()Returns
| Type | Description | 
|---|---|
| System.String | sourceDF | 
getSqlDF()
For getting sqlDF
Declaration
public int getSqlDF()Returns
| Type | Description | 
|---|---|
| System.Int32 | sqlDF | 
getSqlDTV()
For getting sqlDTV
Declaration
public int getSqlDTV()Returns
| Type | Description | 
|---|---|
| System.Int32 | sqlDTV | 
getStrBrackets()
For getting strBrackets
Declaration
public string getStrBrackets()Returns
| Type | Description | 
|---|---|
| System.String | strBrackets | 
getStringDF()
For getting string date format
Declaration
public string getStringDF()Returns
| Type | Description | 
|---|---|
| System.String | If dateFormat is DMY return "DMY" or if is what else. | 
getStringHF()
For getting string hour format
Declaration
public string getStringHF()Returns
| Type | Description | 
|---|---|
| System.String | If hourFormat is HM return "HM" or if is what else. | 
getStringToDate(String)
This method sets SQL date format function as a string depend on RDBMS systems ( MYSQL,SQLSERVER,ORACLE,POSTGRESQL,DB2 ) and return string value.
Declaration
public string getStringToDate(string date)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | date | Date time string value | 
Returns
| Type | Description | 
|---|---|
| System.String | String date time with SQL date formatter form. | 
getTargetDF()
For getting targetDF
Declaration
public string getTargetDF()Returns
| Type | Description | 
|---|---|
| System.String | targetDF | 
selectStrBrackets()
For setting brackets as a string.
Declaration
public void selectStrBrackets()setBrackets(Int32)
For getting brackets
Declaration
public void setBrackets(int brackets)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | brackets | 
setDateFormat(Int32)
For setting dateFormat
Declaration
public void setDateFormat(int dateFormat)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | dateFormat | 
setDbSystem(Int32)
For setting dbSystem
Declaration
public void setDbSystem(int dbSystem)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | dbSystem | 
setFormBrk(Int32)
For setting formBrk
Declaration
public void setFormBrk(int formBrk)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | formBrk | 
setFormDF(Int32)
For setting formDF
Declaration
public void setFormDF(int formDF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | formDF | 
setFormHF(Int32)
For setting formHF
Declaration
public void setFormHF(int formHF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | formHF | 
setHourFormat(Int32)
For setting hourFormat
Declaration
public void setHourFormat(int hourFormat)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | hourFormat | 
setIsCast(Boolean)
For setting isCast
Declaration
public void setIsCast(bool isCast)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | isCast | 
setIsForm(Boolean)
For getting isForm
Declaration
public void setIsForm(bool isForm)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | isForm | 
setIsSimple(Boolean)
For setting isSimple
Declaration
public void setIsSimple(bool isSimple)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | isSimple | 
setSourceDF(String)
For setting sourceDF
Declaration
public void setSourceDF(string sourceDF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | sourceDF | 
setSqlDF(Int32)
For setting sqlDF
Declaration
public void setSqlDF(int sqlDF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | sqlDF | 
setSqlDTV(Int32)
For setting sqlDTV
Declaration
public void setSqlDTV(int sqlDTV)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | sqlDTV | 
setStrBrackets(String)
For getting strBrackets
Declaration
public void setStrBrackets(string strBrackets)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | strBrackets | 
setTargetDF(String)
For setting targetDF
Declaration
public void setTargetDF(string targetDF)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | targetDF |