-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use java8 OffsetDateTime for clients
- Loading branch information
Showing
24 changed files
with
326 additions
and
20 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
modules/openapi-generator/src/main/resources/Java/JavaTimeFormatter.mustache
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,32 @@ | ||
{{>licenseInfo}} | ||
package {{invokerPackage}}; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
|
||
{{>generatedAnnotation}} | ||
public class JavaTimeFormatter { | ||
private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; | ||
public DateTimeFormatter getOffsetDateTimeFormatter() { | ||
return offsetDateTimeFormatter; | ||
} | ||
|
||
public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { | ||
this.offsetDateTimeFormatter = offsetDateTimeFormatter; | ||
} | ||
|
||
public OffsetDateTime parseOffsetDateTime(String str) { | ||
try { | ||
return OffsetDateTime.parse(str, offsetDateTimeFormatter); | ||
} catch (DateTimeParseException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { | ||
return offsetDateTimeFormatter.format(offsetDateTime); | ||
} | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
.../petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.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,43 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
package org.openapitools.client; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
|
||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") | ||
public class JavaTimeFormatter { | ||
|
||
private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; | ||
|
||
public DateTimeFormatter getOffsetDateTimeFormatter() { | ||
return offsetDateTimeFormatter; | ||
} | ||
|
||
public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { | ||
this.offsetDateTimeFormatter = offsetDateTimeFormatter; | ||
} | ||
|
||
public OffsetDateTime parseOffsetDateTime(String str) { | ||
try { | ||
return OffsetDateTime.parse(str, offsetDateTimeFormatter); | ||
} catch (DateTimeParseException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { | ||
return offsetDateTimeFormatter.format(offsetDateTime); | ||
} | ||
} |
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.