-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zonedatetime_support' into graalvm21_java20
- Loading branch information
Showing
18 changed files
with
790 additions
and
72 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
structr-base/src/main/java/org/structr/common/error/ZonedDateTimeFormatToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2010-2024 Structr GmbH | ||
* | ||
* This file is part of Structr <http://structr.org>. | ||
* | ||
* Structr is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Structr is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Structr. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.structr.common.error; | ||
|
||
import org.structr.core.property.PropertyKey; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.Date; | ||
|
||
/** | ||
* Indicates that a given date property has the wrong format. | ||
* | ||
* | ||
*/ | ||
public class ZonedDateTimeFormatToken extends SemanticErrorToken { | ||
|
||
public ZonedDateTimeFormatToken(final String type, PropertyKey<ZonedDateTime> propertyKey) { | ||
super(type, propertyKey, "invalid_date_format"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
structr-base/src/main/java/org/structr/core/converter/TemporalDateConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2010-2024 Structr GmbH | ||
* | ||
* This file is part of Structr <http://structr.org>. | ||
* | ||
* Structr is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Structr is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Structr. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.structr.core.converter; | ||
|
||
import java.time.Instant; | ||
import java.time.ZonedDateTime; | ||
import java.util.Date; | ||
|
||
/** | ||
* Converts java temporal to a regular date object | ||
*/ | ||
public abstract class TemporalDateConverter { | ||
|
||
public static Date convert(final Object inst) { | ||
|
||
if (inst == null) { | ||
return null; | ||
} | ||
|
||
if (inst instanceof Date date) { | ||
|
||
return date; | ||
} else if (inst instanceof ZonedDateTime zdt) { | ||
|
||
return Date.from(zdt.toInstant()); | ||
} else if (inst instanceof Instant i) { | ||
|
||
return Date.from(i); | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.