ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueDate.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueDate.java
Status
scanned
Type
file
Name
ValueDate.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
2618 (2.6 KB)
MD5
040b8738a1b3da0c6b4eeefa662b1590
SHA1
a64a6c8f3857f6047ba822f64e6a00f35d212caa
SHA256
097d24ee6b95e91da76ec817bbe8e5b17d938f421ece66d217e7eba06d310d73
SHA512

      
    
SHA1_git
f370a3d99ff825b239e00756f5b4740f1cf0adcb
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueDate.java | 2.6 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.value; import org.h2.api.ErrorCode; import org.h2.engine.CastDataProvider; import org.h2.message.DbException; import org.h2.util.DateTimeUtils; /** * Implementation of the DATE data type. */ public final class ValueDate extends Value { /** * The default precision and display size of the textual representation of a date. * Example: 2000-01-02 */ public static final int PRECISION = 10; private final long dateValue; private ValueDate(long dateValue) { if (dateValue < DateTimeUtils.MIN_DATE_VALUE || dateValue > DateTimeUtils.MAX_DATE_VALUE) { throw new IllegalArgumentException("dateValue out of range " + dateValue); } this.dateValue = dateValue; } /** * Get or create a date value for the given date. * * @param dateValue the date value * @return the value */ public static ValueDate fromDateValue(long dateValue) { return (ValueDate) Value.cache(new ValueDate(dateValue)); } /** * Parse a string to a ValueDate. * * @param s the string to parse * @return the date */ public static ValueDate parse(String s) { try { return fromDateValue(DateTimeUtils.parseDateValue(s, 0, s.length())); } catch (Exception e) { throw DbException.get(ErrorCode.INVALID_DATETIME_CONSTANT_2, e, "DATE", s); } } public long getDateValue() { return dateValue; } @Override public TypeInfo getType() { return TypeInfo.TYPE_DATE; } @Override public int getValueType() { return DATE; } @Override public String getString() { return DateTimeUtils.appendDate(new StringBuilder(PRECISION), dateValue).toString(); } @Override public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { return DateTimeUtils.appendDate(builder.append("DATE '"), dateValue).append('\''); } @Override public int compareTypeSafe(Value o, CompareMode mode, CastDataProvider provider) { return Long.compare(dateValue, ((ValueDate) o).dateValue); } @Override public boolean equals(Object other) { return this == other || other instanceof ValueDate && dateValue == ((ValueDate) other).dateValue; } @Override public int hashCode() { return (int) (dateValue ^ (dateValue >>> 32)); } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
3.36
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220