Skip to content

Commit

Permalink
Merge pull request #240 from satsen/remove-sql
Browse files Browse the repository at this point in the history
Removed SQL Date references
  • Loading branch information
kushti authored Oct 28, 2024
2 parents 7edd598 + 14242be commit c1d939d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public ExplorerApiClient setDateFormat(DateFormat dateFormat) {
return this;
}

public ExplorerApiClient setSqlDateFormat(DateFormat dateFormat) {
this.json.setSqlDateFormat(dateFormat);
return this;
}

public ExplorerApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
public class JSON {
private Gson gson;
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();

Expand Down Expand Up @@ -70,7 +69,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
public JSON() {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.create();
Expand Down Expand Up @@ -191,61 +189,6 @@ public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
return this;
}

/**
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
* (more efficient than SimpleDateFormat).
*/
public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {

private DateFormat dateFormat;

public SqlDateTypeAdapter() {
}

public SqlDateTypeAdapter(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

public void setFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

@Override
public void write(JsonWriter out, java.sql.Date date) throws IOException {
if (date == null) {
out.nullValue();
} else {
String value;
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toString();
}
out.value(value);
}
}

@Override
public java.sql.Date read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
try {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
}
}
}

/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, ISO8601Utils will be used.
Expand Down Expand Up @@ -309,9 +252,4 @@ public JSON setDateFormat(DateFormat dateFormat) {
return this;
}

public JSON setSqlDateFormat(DateFormat dateFormat) {
sqlDateTypeAdapter.setFormat(dateFormat);
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ public ApiClient setDateFormat(DateFormat dateFormat) {
return this;
}

public ApiClient setSqlDateFormat(DateFormat dateFormat) {
this.json.setSqlDateFormat(dateFormat);
return this;
}

public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
public class JSON {
private Gson gson;
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();

Expand Down Expand Up @@ -136,7 +135,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
public JSON() {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.create();
Expand Down Expand Up @@ -257,61 +255,6 @@ public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
return this;
}

/**
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
* (more efficient than SimpleDateFormat).
*/
public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {

private DateFormat dateFormat;

public SqlDateTypeAdapter() {
}

public SqlDateTypeAdapter(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

public void setFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

@Override
public void write(JsonWriter out, java.sql.Date date) throws IOException {
if (date == null) {
out.nullValue();
} else {
String value;
if (dateFormat != null) {
value = dateFormat.format(date);
} else {
value = date.toString();
}
out.value(value);
}
}

@Override
public java.sql.Date read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
try {
if (dateFormat != null) {
return new java.sql.Date(dateFormat.parse(date).getTime());
}
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
} catch (ParseException e) {
throw new JsonParseException(e);
}
}
}
}

/**
* Gson TypeAdapter for java.util.Date type
* If the dateFormat is null, ISO8601Utils will be used.
Expand Down Expand Up @@ -375,9 +318,4 @@ public JSON setDateFormat(DateFormat dateFormat) {
return this;
}

public JSON setSqlDateFormat(DateFormat dateFormat) {
sqlDateTypeAdapter.setFormat(dateFormat);
return this;
}

}

0 comments on commit c1d939d

Please sign in to comment.