ICU 75.1 75.1
Loading...
Searching...
No Matches
Public Member Functions | Friends
icu::FormattedDateInterval Class Reference

An immutable class containing the result of a date interval formatting operation. More...

#include <dtitvfmt.h>

Inheritance diagram for icu::FormattedDateInterval:
icu::UMemory icu::FormattedValue

Public Member Functions

 FormattedDateInterval ()
 Default constructor; makes an empty FormattedDateInterval.
 
 FormattedDateInterval (FormattedDateInterval &&src) noexcept
 Move constructor: Leaves the source FormattedDateInterval in an undefined state.
 
virtual ~FormattedDateInterval () override
 Destruct an instance of FormattedDateInterval.
 
 FormattedDateInterval (const FormattedDateInterval &)=delete
 Copying not supported; use move constructor instead.
 
FormattedDateIntervaloperator= (const FormattedDateInterval &)=delete
 Copying not supported; use move assignment instead.
 
FormattedDateIntervaloperator= (FormattedDateInterval &&src) noexcept
 Move assignment: Leaves the source FormattedDateInterval in an undefined state.
 
UnicodeString toString (UErrorCode &status) const override
 Returns the formatted string as a self-contained UnicodeString.
 
UnicodeString toTempString (UErrorCode &status) const override
 Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
 
AppendableappendTo (Appendable &appendable, UErrorCode &status) const override
 Appends the formatted string to an Appendable.
 
UBool nextPosition (ConstrainedFieldPosition &cfpos, UErrorCode &status) const override
 Iterates over field positions in the FormattedValue.
 
- Public Member Functions inherited from icu::FormattedValue
virtual ~FormattedValue ()
 

Friends

class DateIntervalFormat
 

Detailed Description

An immutable class containing the result of a date interval formatting operation.

Instances of this class are immutable and thread-safe.

When calling nextPosition(): The fields are returned from left to right. The special field category UFIELD_CATEGORY_DATE_INTERVAL_SPAN is used to indicate which datetime primitives came from which arguments: 0 means fromCalendar, and 1 means toCalendar. The span category will always occur before the corresponding fields in UFIELD_CATEGORY_DATE in the nextPosition() iterator.

Not intended for public subclassing.

Stable:
ICU 64

Definition at line 59 of file dtitvfmt.h.

Constructor & Destructor Documentation

◆ FormattedDateInterval() [1/2]

icu::FormattedDateInterval::FormattedDateInterval ( )
inline

Default constructor; makes an empty FormattedDateInterval.

Stable:
ICU 64

Definition at line 65 of file dtitvfmt.h.

◆ FormattedDateInterval() [2/2]

icu::FormattedDateInterval::FormattedDateInterval ( FormattedDateInterval &&  src)
noexcept

Move constructor: Leaves the source FormattedDateInterval in an undefined state.

Stable:
ICU 64

◆ ~FormattedDateInterval()

virtual icu::FormattedDateInterval::~FormattedDateInterval ( )
overridevirtual

Destruct an instance of FormattedDateInterval.

Stable:
ICU 64

Member Function Documentation

◆ appendTo()

Appendable & icu::FormattedDateInterval::appendTo ( Appendable appendable,
UErrorCode status 
) const
overridevirtual

Appends the formatted string to an Appendable.

Parameters
appendableThe Appendable to which to append the string output.
statusSet if an error occurs.
Returns
The same Appendable, for chaining.
Stable:
ICU 64
See also
Appendable

Implements icu::FormattedValue.

◆ nextPosition()

UBool icu::FormattedDateInterval::nextPosition ( ConstrainedFieldPosition cfpos,
UErrorCode status 
) const
overridevirtual

Iterates over field positions in the FormattedValue.

This lets you determine the position of specific types of substrings, like a month or a decimal separator.

To loop over all field positions:

ConstrainedFieldPosition cfpos;
while (fmtval.nextPosition(cfpos, status)) {
    // handle the field position; get information from cfpos
}
Parameters
cfposThe object used for iteration state. This can provide constraints to iterate over only one specific category or field; see ConstrainedFieldPosition::constrainCategory and ConstrainedFieldPosition::constrainField.
statusSet if an error occurs.
Returns
true if a new occurrence of the field was found; false otherwise or if an error was set.
Stable:
ICU 64

Implements icu::FormattedValue.

◆ operator=()

FormattedDateInterval & icu::FormattedDateInterval::operator= ( FormattedDateInterval &&  src)
noexcept

Move assignment: Leaves the source FormattedDateInterval in an undefined state.

Stable:
ICU 64

◆ toString()

UnicodeString icu::FormattedDateInterval::toString ( UErrorCode status) const
overridevirtual

Returns the formatted string as a self-contained UnicodeString.

If you need the string within the current scope only, consider toTempString.

Parameters
statusSet if an error occurs.
Returns
a UnicodeString containing the formatted string.
Stable:
ICU 64

Implements icu::FormattedValue.

◆ toTempString()

UnicodeString icu::FormattedDateInterval::toTempString ( UErrorCode status) const
overridevirtual

Returns the formatted string as a read-only alias to memory owned by the FormattedValue.

The return value is valid only as long as this FormattedValue is present and unchanged in memory. If you need the string outside the current scope, consider toString.

The buffer returned by calling UnicodeString::getBuffer() on the return value is guaranteed to be NUL-terminated.

Parameters
statusSet if an error occurs.
Returns
a temporary UnicodeString containing the formatted string.
Stable:
ICU 64

Implements icu::FormattedValue.

Friends And Related Symbol Documentation

◆ DateIntervalFormat

Definition at line 110 of file dtitvfmt.h.


The documentation for this class was generated from the following file: