// Mutex, protects access to fDateFormat, fFromCalendar and fToCalendar.
// Needed because these data members are modified by const methods of DateIntervalFormat.
-static UMutex *gFormatterMutex() {
- static UMutex *m = STATIC_NEW(UMutex);
- return m;
-}
+static UMutex gFormatterMutex;
DateIntervalFormat* U_EXPORT2
DateIntervalFormat::createInstance(const UnicodeString& skeleton,
delete fTimePattern;
delete fDateTimeFormat;
{
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
if ( itvfmt.fDateFormat ) {
- fDateFormat = (SimpleDateFormat*)itvfmt.fDateFormat->clone();
+ fDateFormat = itvfmt.fDateFormat->clone();
} else {
fDateFormat = NULL;
}
}
-Format*
-DateIntervalFormat::clone(void) const {
+DateIntervalFormat*
+DateIntervalFormat::clone() const {
return new DateIntervalFormat(*this);
}
if ((fInfo != fmt->fInfo) && (fInfo == NULL || fmt->fInfo == NULL)) {return FALSE;}
if (fInfo && fmt->fInfo && (*fInfo != *fmt->fInfo )) {return FALSE;}
{
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
if (fDateFormat != fmt->fDateFormat && (fDateFormat == NULL || fmt->fDateFormat == NULL)) {return FALSE;}
if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;}
}
handler.setAcceptFirstOnly(TRUE);
int8_t ignore;
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
return formatIntervalImpl(*dtInterval, appendTo, ignore, handler, status);
}
auto handler = result->getHandler(status);
handler.setCategory(UFIELD_CATEGORY_DATE);
{
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
formatIntervalImpl(dtInterval, string, firstIndex, handler, status);
}
handler.getError(status);
handler.setAcceptFirstOnly(TRUE);
int8_t ignore;
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
return formatImpl(fromCalendar, toCalendar, appendTo, ignore, handler, status);
}
auto handler = result->getHandler(status);
handler.setCategory(UFIELD_CATEGORY_DATE);
{
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
formatImpl(fromCalendar, toCalendar, string, firstIndex, handler, status);
}
handler.getError(status);
DateIntervalFormat::getTimeZone() const
{
if (fDateFormat != NULL) {
- Mutex lock(gFormatterMutex());
+ Mutex lock(&gFormatterMutex);
return fDateFormat->getTimeZone();
}
// If fDateFormat is NULL (unexpected), create default timezone.
UBool formatDatePlusTimeRange = (fromToOnSameDay && fDatePattern && fTimePattern);
if (formatDatePlusTimeRange) {
- SimpleFormatter sf(*fDateTimeFormat, 2, 2, status);
+ SimpleFormatter sf(*fDateTimeFormat, 2, 2, TRUE, status);
if (U_FAILURE(status)) {
return appendTo;
}