Table of Contents

Class FastDateTimeParser

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Provides methods to parse and format date and time strings using a fast custom parser.

public class FastDateTimeParser
Inheritance
FastDateTimeParser
Inherited Members
Extension Methods

Constructors

FastDateTimeParser(string)

Initializes a new instance of the FastDateTimeParser class with the specified format template.

public FastDateTimeParser(string template)

Parameters

template string

The date and time format template.

Exceptions

ArgumentNullException

Thrown when the template is null or empty.

Properties

Template

Gets the date and time format template used for parsing and formatting.

public string Template { get; }

Property Value

string

Methods

Parse(string)

Parses the specified input string into a DateTime based on the predefined template.

public DateTime Parse(string input)

Parameters

input string

The string input representing the date and time.

Returns

DateTime

A DateTime object parsed from the input string.

Exceptions

InvalidCastException

Thrown when the input cannot be parsed into a valid DateTime.

ParseDto(string)

Parses the specified input string into a DateTimeOffset based on the predefined template, applying the time zone if specified.

public DateTimeOffset ParseDto(string input)

Parameters

input string

The string input representing the date and time with time zone.

Returns

DateTimeOffset

A DateTimeOffset object parsed from the input string.

ToString()

public override string ToString()

Returns

string

ToString(DateTime)

Converts the specified DateTime to its string representation based on the predefined template.

public string ToString(DateTime value)

Parameters

value DateTime

The DateTime value to format.

Returns

string

A string representation of the date and time.