1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.item.atomic.impl;
7   
8   import java.time.ZonedDateTime;
9   
10  import dev.metaschema.core.datatype.adapter.DateAdapter;
11  import dev.metaschema.core.datatype.adapter.MetaschemaDataTypeProvider;
12  import dev.metaschema.core.datatype.object.AmbiguousDate;
13  import edu.umd.cs.findbugs.annotations.NonNull;
14  
15  /**
16   * An implementation of a Metapath atomic item containing a date data value that
17   * may not have an explicit timezone.
18   */
19  public class DateWithoutTimeZoneItemImpl
20      extends AbstractDateItem<AmbiguousDate> {
21  
22    /**
23     * Construct a new item with the provided {@code value}.
24     *
25     * @param value
26     *          the value to wrap
27     */
28    public DateWithoutTimeZoneItemImpl(@NonNull AmbiguousDate value) {
29      super(value);
30    }
31  
32    @Override
33    public boolean hasTimezone() {
34      return getJavaTypeAdapter().toValue(getValue()).hasTimeZone();
35    }
36  
37    @Override
38    public ZonedDateTime asZonedDateTime() {
39      return getValue().getValue();
40    }
41  
42    @Override
43    public DateAdapter getJavaTypeAdapter() {
44      return MetaschemaDataTypeProvider.DATE;
45    }
46  }