Skip to content

Commit

Permalink
- Added missing copyright headers
Browse files Browse the repository at this point in the history
- Removed final use of DateUtilities.parseDate(1 arg) from java-util usage.  Favor using parseDate(3 args)
  • Loading branch information
jdereg committed Jan 28, 2024
1 parent e21094c commit 333788e
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class AtomicBooleanConversions {

static Byte toByte(Object from, Converter converter, ConverterOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class CalendarConversions {

static Date toDate(Object from) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class CharacterConversions {

private CharacterConversions() {
Expand Down
42 changes: 18 additions & 24 deletions src/main/java/com/cedarsoftware/util/convert/DateConversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class DateConversions {

static long toLong(Object from) {
Expand All @@ -32,37 +49,14 @@ static long toLong(Object from, Converter converter, ConverterOptions options) {
return toLong(from);
}

/**
* The input can be any of our Date type objects (java.sql.Date, Timestamp, Date, etc.) coming in so
* we need to force the conversion by creating a new instance.
* @param from - one of the date objects
* @param converter - converter instance
* @param options - converter options
* @return newly created java.sql.Date
*/
static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) {
return new java.sql.Date(toLong(from));
}

/**
* The input can be any of our Date type objects (java.sql.Date, Timestamp, Date, etc.) coming in so
* we need to force the conversion by creating a new instance.
* @param from - one of the date objects
* @param converter - converter instance
* @param options - converter options
* @return newly created Date
*/ static Date toDate(Object from, Converter converter, ConverterOptions options) {
static Date toDate(Object from, Converter converter, ConverterOptions options) {
return new Date(toLong(from));
}

/**
* The input can be any of our Date type objects (java.sql.Date, Timestamp, Date, etc.) coming in so
* we need to force the conversion by creating a new instance.
* @param from - one of the date objects
* @param converter - converter instance
* @param options - converter options
* @return newly created Timestamp
*/
static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) {
return new Timestamp(toLong(from));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
import java.util.GregorianCalendar;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class LocalDateConversions {

private static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
import java.util.GregorianCalendar;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class LocalDateTimeConversions {
private static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) {
return ((LocalDateTime)from).atZone(options.getSourceZoneIdForLocalDates()).withZoneSameInstant(options.getZoneId());
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/cedarsoftware/util/convert/MapConversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
import com.cedarsoftware.util.ArrayUtilities;
import com.cedarsoftware.util.Convention;

/**
* @author John DeRegnaucourt ([email protected])
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class MapConversions {

private static final String V = "_v";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ static Instant toInstant(Object from, Converter converter, ConverterOptions opti
try {
return Instant.parse(s);
} catch (Exception e) {
Date date = DateUtilities.parseDate(s);
return date == null ? null : date.toInstant();
return getInstant(s, options);
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/cedarsoftware/util/convert/UUIDConversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
import java.math.BigInteger;
import java.util.UUID;

/**
* @author John DeRegnaucourt ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public final class UUIDConversions {

private UUIDConversions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author Kenny Partlow ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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.
*/
public class ZonedDateTimeConversions {

static ZonedDateTime toDifferentZone(Object from, ConverterOptions options) {
Expand Down

0 comments on commit 333788e

Please sign in to comment.