Checks if the visited field is of type {@link java.util.Calendar} or
{@link java.text.DateFormat} or a subclass of either one. If so and the
field is static and non-private it is suspicious and will be reported.
328226
@Override
    public void visit(Field aField) {
        if (aField.isPrivate()) {
            /*
             * private fields are harmless, as long as they are used correctly
             * inside their own class. This should be something the rest of this
             * detector can find out, so do not report them, they might be false
             * positives.
             */
            return;
        }
        String superclassName = getSuperclassName();
        if (!aField.isStatic() && !"java/lang/Enum".equals(superclassName)) {
            return;
        }
        if (!aField.isPublic() && !aField.isProtected()) {
            return;
        }
        ClassDescriptor classOfField = DescriptorFactory.createClassDescriptorFromFieldSignature(aField.getSignature());
        String tBugType = null;
        int priority = aField.isPublic() && aField.isFinal() && aField.getName().equals(aField.getName().toUpperCase())
                && getThisClass().isPublic() ? HIGH_PRIORITY : NORMAL_PRIORITY;
        if (classOfField != null) {
            try {
                if (subtypes2.isSubtype(classOfField, calendarType)) {
                    tBugType = "STCAL_STATIC_CALENDAR_INSTANCE";
                    priority++;
                } else if (subtypes2.isSubtype(classOfField, dateFormatType)) {
                    tBugType = "STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE";
                }
                if (getClassContext().getXClass().usesConcurrency()) {
                    priority--;
                }
                if (tBugType != null) {

                    pendingBugs.put(getXField(), new BugInstance(this, tBugType, priority).addClass(currentClass).addField(this));
                }
            } catch (ClassNotFoundException e) {
                AnalysisContext.reportMissingClass(e);
            }
        }

    }
1323503
private DateHistogramAggregationBuilder dateHistogram(MethodField field) throws SqlParseException {
        String alias = gettAggNameFromParamsOrAlias(field);
        DateHistogramAggregationBuilder dateHistogram = AggregationBuilders.dateHistogram(alias).format(TIME_FARMAT);
        String value = null;
        for (KVValue kv : field.getParams()) {
            if(kv.value.toString().contains("doc[")) {
                String script = kv.value +  "; return " + kv.key;
                dateHistogram.script(new Script(script));
            } else {
                value = kv.value.toString();
                switch (kv.key.toLowerCase()) {
                    case "interval":
                        dateHistogram.dateHistogramInterval(new DateHistogramInterval(kv.value.toString()));
                        break;
                    case "field":
                        dateHistogram.field(value);
                        break;
                    case "format":
                        dateHistogram.format(value);
                        break;
                    case "time_zone":
                        dateHistogram.timeZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(ZoneOffset.of(value))));
                        break;
                    case "min_doc_count":
                        dateHistogram.minDocCount(Long.parseLong(value));
                        break;
                    case "order":
                        dateHistogram.order("desc".equalsIgnoreCase(value) ? BucketOrder.key(false) : BucketOrder.key(true));
                        break;
                    case "extended_bounds":
                        ExtendedBounds extendedBounds = null;
                        try (JsonXContentParser parser = new JsonXContentParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, new JsonFactory().createParser(value))) {
                            extendedBounds = ExtendedBounds.PARSER.parse(parser, null);
                        } catch (IOException ex) {
                            List<Integer> indexList = new LinkedList<>();
                            int index = -1;
                            while ((index = value.indexOf(':', index + 1)) != -1) {
                                indexList.add(index);
                            }
                            if (!indexList.isEmpty()) {
                                index = indexList.get(indexList.size() / 2);
                                extendedBounds = new ExtendedBounds(value.substring(0, index), value.substring(index + 1));
                            }
                        }
                        if (extendedBounds != null) {
                            dateHistogram.extendedBounds(extendedBounds);
                        }
                        break;
                    case "offset":
                        dateHistogram.offset(value);
                        break;

                    case "alias":
                    case "nested":
                    case "reverse_nested":
                    case "children":
                        break;
                    default:
                        throw new SqlParseException("date range err or not define field " + kv.toString());
                }
            }
        }
        return dateHistogram;
    }
907160
@Override
  public boolean isTimeIncluded (final long timeStamp)
  {
    if (m_aExcludeAll == true)
    {
      return false;
    }

    // Test the base calendar first. Only if the base calendar not already
    // excludes the time/date, continue evaluating this calendar instance.
    if (super.isTimeIncluded (timeStamp) == false)
    {
      return false;
    }

    final Calendar cl = createJavaCalendar (timeStamp);
    final int day = cl.get (Calendar.DAY_OF_MONTH);

    return !(isDayExcluded (day));
  }
1148258
private static boolean isPropertyType(Class<?> type) {
        return type.isPrimitive() ||
                type == String.class ||
                type == Date.class ||
                type == Calendar.class ||
                ClassUtils.wrapperToPrimitive(type) != null;
    }
217769
public boolean insideRange(Calendar startDate,
			       Calendar endDate) {
	// make a copy of the start time so that it is safe to modify it without
	// affecting the input parameter
	Calendar mutableStartDate = (Calendar)(startDate.clone());
	return isInRange(mutableStartDate, endDate);
    }
541200
@Check(CheckType.FAST)
	public void checkFieldName(SarlField field) {
		final JvmField inferredType = this.associations.getJvmField(field);
		final QualifiedName name = Utils.getQualifiedName(inferredType);
		if (this.featureNames.isDisallowedName(name)) {
			final String validName = Utils.fixHiddenMember(field.getName());
			error(MessageFormat.format(
					Messages.SARLValidator_41,
					field.getName()),
					field,
					XTEND_FIELD__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
					VARIABLE_NAME_DISALLOWED,
					validName);
		} else if (this.grammarAccess.getOccurrenceKeyword().equals(field.getName())) {
			error(MessageFormat.format(
					Messages.SARLValidator_41,
					this.grammarAccess.getOccurrenceKeyword()),
					field,
					XTEND_FIELD__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
					VARIABLE_NAME_DISALLOWED);
		}
	}
1206925
private void checkAndUpdate(DurationFieldType type, int[] values, int newValue) {
        int index = indexOf(type);
        if (index == -1) {
            if (newValue != 0) {
                throw new IllegalArgumentException(
                    "Period does not support field '" + type.getName() + "'");
            }
        } else {
            values[index] = newValue;
        }
    }
972454
private static boolean isDate(String value) {
    try {
      new SimpleDateFormat("yyyyMMddHHmmss").parse(value);
      return true;
    } catch (ParseException e) {
      return false;
    }
  }
754768
private void assertValidDateFieldType(Optional<Field> field) {

		field.ifPresent(it -> {

			if (SUPPORTED_DATE_TYPES.contains(it.getType().getName())) {
				return;
			}

			Class<?> type = it.getType();

			if (Jsr310Converters.supports(type)
					|| ThreeTenBackPortConverters.supports(type)) {
				return;
			}

			throw new IllegalStateException(String.format(
					"Found created/modified date field with type %s but only %s as well as java.time types are supported!",
					type, SUPPORTED_DATE_TYPES));
		});
	}
940936
@Nullable
    private String isFieldCollection(OpcodeStack.Item item) throws ClassNotFoundException {
        Comparable<?> aliasReg = (Comparable<?>) item.getUserValue();
        if (aliasReg instanceof String) {
            return (String) aliasReg;
        }

        XField field = item.getXField();
        if (field == null) {
            return null;
        }

        JavaClass cls = item.getJavaClass();
        if ((cls != null) && cls.implementationOf(collectionClass)) {
            return field.getName();
        }

        return null;
    }
455480
boolean check(Calendar cal) {

        Calendar checkCal = cal;

        if(specTimezone != null && !specTimezone.isEmpty()) {
            Calendar tzCal = Calendar.getInstance(TimeZone.getTimeZone(specTimezone));
            tzCal.setTime(cal.getTime());
            checkCal = tzCal;
        }

        if(!checkBits(bits[0],checkCal.get(MINUTE)))
            return false;
        if(!checkBits(bits[1],checkCal.get(HOUR_OF_DAY)))
            return false;
        if(!checkBits(bits[2],checkCal.get(DAY_OF_MONTH)))
            return false;
        if(!checkBits(bits[3],checkCal.get(MONTH)+1))
            return false;
        if(!checkBits(dayOfWeek,checkCal.get(Calendar.DAY_OF_WEEK)-1))
            return false;

        return true;
    }
499408
@Override
    public ValueRange range(TemporalField field) {
        if (field instanceof ChronoField) {
            if (isSupported(field)) {
                // day 29 is treated as being outside the normal week
                ChronoField f = (ChronoField) field;
                switch (f) {
                    case ALIGNED_DAY_OF_WEEK_IN_MONTH:
                    case ALIGNED_DAY_OF_WEEK_IN_YEAR:
                    case DAY_OF_WEEK:
                        return isSpecialDay() ? EMPTY_RANGE : ValueRange.of(1, DAYS_IN_WEEK);
                    case ALIGNED_WEEK_OF_MONTH:
                        return isSpecialDay() ? EMPTY_RANGE : ValueRange.of(1, WEEKS_IN_MONTH);
                    case ALIGNED_WEEK_OF_YEAR:
                        return isSpecialDay() ? EMPTY_RANGE : ValueRange.of(1, WEEKS_IN_YEAR);
                    case DAY_OF_MONTH:
                        return ValueRange.of(1, lengthOfMonth());
                    case DAY_OF_YEAR:
                        return isLeapYear ? DAY_OF_YEAR_LEAP_RANGE : DAY_OF_YEAR_NORMAL_RANGE;
                    case EPOCH_DAY:
                        return EPOCH_DAY_RANGE;
                    case ERA:
                        return ERA_RANGE;
                    case MONTH_OF_YEAR:
                        return MONTH_OF_YEAR_RANGE;
                    default:
                        break;
                }
            } else {
                throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
            }
        }
        return super.range(field);
    }
660244
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case TIMESTAMP:
      return isSetTimestamp();
    case VALUE:
      return isSetValue();
    case HOST:
      return isSetHost();
    }
    throw new java.lang.IllegalStateException();
  }
343144
@Override
    public boolean isSupported(TemporalField field) {
        if (fieldValues.containsKey(field) ||
                (date != null && date.isSupported(field)) ||
                (time != null && time.isSupported(field))) {
            return true;
        }
        return field != null && (field instanceof ChronoField == false) && field.isSupportedBy(this);
    }
868517
private boolean checkDateTimeFormat(String pstrDtFmt)
    {
        boolean    blnRet = false;
        DateFormat objFmt = null;

        try
        {
            objFmt = new SimpleDateFormat(pstrDtFmt);
            blnRet = true;
        }
        catch (NullPointerException NPExIgnore)
        {
        }
        catch (IllegalArgumentException IAExIgnore)
        {
        }
        finally
        {
            if (objFmt != null) objFmt = null;
        }
        return blnRet;
    }
779234
public static int getBeginValue(Calendar calendar, int dateField) {
		if(Calendar.DAY_OF_WEEK == dateField) {
			return calendar.getFirstDayOfWeek();
		}
		return calendar.getActualMinimum(dateField);
	}
128563
static Date parseDate(String dateString) {
    try {
      return DATE_FORMAT.parseDateTime(dateString).toDate();
    } catch (IllegalArgumentException e) {
      return null;
    }
  }