-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tests to the PR --Glenn
- Loading branch information
Showing
7 changed files
with
201 additions
and
16 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...n/java/org/springframework/cloud/dataflow/server/converter/AbstractDateTimeConverter.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,38 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.cloud.dataflow.server.converter; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* Base class for date/time converters. | ||
* To be discarded when moving to Boot 3.x and the converters from org.springframework.batch.core.converter used instead. | ||
* @author Mahmoud Ben Hassine | ||
* @author Corneil du Plessis | ||
* @since 2.11.2 | ||
*/ | ||
@Deprecated | ||
class AbstractDateTimeConverter { | ||
|
||
protected DateTimeFormatter instantFormatter = DateTimeFormatter.ISO_INSTANT; | ||
|
||
protected DateTimeFormatter localDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE; | ||
|
||
protected DateTimeFormatter localTimeFormatter = DateTimeFormatter.ISO_LOCAL_TIME; | ||
|
||
protected DateTimeFormatter localDateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
.../main/java/org/springframework/cloud/dataflow/server/converter/DateToStringConverter.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,40 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.cloud.dataflow.server.converter; | ||
|
||
import java.util.Date; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
|
||
/** | ||
* {@link Converter} implementation from {@link Date} to {@link String}. | ||
* To be discarded when moving to Boot 3.x and the converters from org.springframework.batch.core.converter used instead. | ||
* This converter formats dates according to the | ||
* {@link java.time.format.DateTimeFormatter#ISO_INSTANT} format. | ||
* To be discarded when moving to Boot 3.x and the converters from org.springframework.batch.core.converter used instead. | ||
* @author Mahmoud Ben Hassine | ||
* @author Corneil du Plessis | ||
* @since 2.11.2 | ||
*/ | ||
@Deprecated | ||
public class DateToStringConverter extends AbstractDateTimeConverter implements Converter<Date, String> { | ||
|
||
@Override | ||
public String convert(Date source) { | ||
return super.instantFormatter.format(source.toInstant()); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
.../main/java/org/springframework/cloud/dataflow/server/converter/StringToDateConverter.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,41 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.cloud.dataflow.server.converter; | ||
|
||
import java.time.Instant; | ||
import java.util.Date; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
|
||
/** | ||
* {@link Converter} implementation from {@link String} to {@link Date}. | ||
* | ||
* This converter expects strings in the | ||
* {@link java.time.format.DateTimeFormatter#ISO_INSTANT} format. | ||
* To be discarded when moving to Boot 3.x and the converters from org.springframework.batch.core.converter used instead. | ||
* @author Mahmoud Ben Hassine | ||
* @author Corneil du Plessis | ||
* @since 2.11.2 | ||
*/ | ||
@Deprecated | ||
public class StringToDateConverter extends AbstractDateTimeConverter implements Converter<String, Date> { | ||
|
||
@Override | ||
public Date convert(String source) { | ||
return Date.from(super.instantFormatter.parse(source, Instant::from)); | ||
} | ||
|
||
} |
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