Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Oct 20, 2023
1 parent 6d85ba2 commit 897b361
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
import com.github.jlangch.venice.impl.types.util.Types;
import com.github.jlangch.venice.impl.util.ArityExceptions;
import com.github.jlangch.venice.impl.util.SymbolMapBuilder;
import com.github.jlangch.venice.impl.util.TimeUnitUtil;
import com.github.jlangch.venice.impl.util.callstack.CallFrame;
import com.github.jlangch.venice.impl.util.time.TimeUnitUtil;


public class ConcurrencyFunctions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import com.github.jlangch.venice.impl.types.util.Coerce;
import com.github.jlangch.venice.impl.util.ArityExceptions;
import com.github.jlangch.venice.impl.util.SymbolMapBuilder;
import com.github.jlangch.venice.impl.util.TimeUnitUtil;
import com.github.jlangch.venice.impl.util.callstack.CallFrame;
import com.github.jlangch.venice.impl.util.time.TimeUnitUtil;


public class ScheduleFunctions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
import com.github.jlangch.venice.impl.types.util.Types;
import com.github.jlangch.venice.impl.util.ArityExceptions;
import com.github.jlangch.venice.impl.util.SymbolMapBuilder;
import com.github.jlangch.venice.impl.util.TimeUtil;
import com.github.jlangch.venice.impl.util.reflect.ReflectionAccessor;
import com.github.jlangch.venice.impl.util.time.TimeUtil;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.github.jlangch.venice.ExcelException;
import com.github.jlangch.venice.impl.util.TimeUtil;
import com.github.jlangch.venice.impl.util.time.TimeUtil;
import com.github.jlangch.venice.util.excel.CellAddr;
import com.github.jlangch.venice.util.excel.CellRangeAddr;
import com.github.jlangch.venice.util.excel.chart.AreaDataSeries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.github.jlangch.venice.impl.types.collections.VncSequence;
import com.github.jlangch.venice.impl.types.collections.VncSet;
import com.github.jlangch.venice.impl.types.util.Types;
import com.github.jlangch.venice.impl.util.time.ISODateTime;
import com.github.jlangch.venice.nanojson.JsonAppendableWriter;

public class VncJsonWriter {
Expand Down Expand Up @@ -351,7 +352,7 @@ else if (Types.isVncLong(k)) {
private void write_VncJavaObject(final String key, final VncJavaObject val) {
final Object delegate = val.getDelegate();
if (delegate instanceof LocalDate) {
final String formatted = JsonDateTime.formatISO((LocalDate)delegate);
final String formatted = ISODateTime.formatISO((LocalDate)delegate);
if (key == null) {
writer.value(formatted);
}
Expand All @@ -360,7 +361,7 @@ private void write_VncJavaObject(final String key, final VncJavaObject val) {
}
}
else if (delegate instanceof LocalDateTime) {
final String formatted = JsonDateTime.formatISO((LocalDateTime)delegate);
final String formatted = ISODateTime.formatISO((LocalDateTime)delegate);
if (key == null) {
writer.value(formatted);
}
Expand All @@ -369,7 +370,7 @@ else if (delegate instanceof LocalDateTime) {
}
}
else if (delegate instanceof ZonedDateTime) {
final String formatted = JsonDateTime.formatISO((ZonedDateTime)delegate);
final String formatted = ISODateTime.formatISO((ZonedDateTime)delegate);
if (key == null) {
writer.value(formatted);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jlangch.venice.impl.util.json;
package com.github.jlangch.venice.impl.util.time;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;


public class JsonDateTime {
public class ISODateTime {

public static String formatISO(final LocalDate date) {
return date == null ? null : date.format(FMT_LOCAL_DATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jlangch.venice.impl.util;
package com.github.jlangch.venice.impl.util.time;

import java.util.concurrent.TimeUnit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jlangch.venice.impl.util;
package com.github.jlangch.venice.impl.util.time;

import java.time.Instant;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jlangch.venice.impl.util.json;
package com.github.jlangch.venice.impl.util.time;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -31,8 +31,10 @@

import org.junit.jupiter.api.Test;

import com.github.jlangch.venice.impl.util.time.ISODateTime;

public class JsonDateTimeTest {

public class ISODateTimeTest {

@Test
public void test_format_ISO() {
Expand All @@ -41,23 +43,23 @@ public void test_format_ISO() {
final LocalTime lt0 = LocalTime.of(10, 45, 30, 0);
final ZoneId zoneId = ZoneId.of("Europe/Paris");

assertEquals("2023-10-25", JsonDateTime.formatISO(ld));
assertEquals("2023-10-25", ISODateTime.formatISO(ld));

assertEquals("2023-10-25T10:45:30.851", JsonDateTime.formatISO(LocalDateTime.of(ld, lt)));
assertEquals("2023-10-25T10:45:30", JsonDateTime.formatISO(LocalDateTime.of(ld, lt0)));
assertEquals("2023-10-25T10:45:30.851", ISODateTime.formatISO(LocalDateTime.of(ld, lt)));
assertEquals("2023-10-25T10:45:30", ISODateTime.formatISO(LocalDateTime.of(ld, lt0)));

assertEquals("2023-10-25T10:45:30.851+02:00", JsonDateTime.formatISO(ZonedDateTime.of(ld, lt, zoneId)));
assertEquals("2023-10-25T10:45:30.851+02:00", ISODateTime.formatISO(ZonedDateTime.of(ld, lt, zoneId)));
}

@Test
public void test_parse_ISO() {
assertEquals("2023-10-25", JsonDateTime.parseISO_LocalDate("2023-10-25").toString());
assertEquals("2023-10-25", ISODateTime.parseISO_LocalDate("2023-10-25").toString());

assertEquals("2023-10-25T10:45:30.851", JsonDateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.851").toString());
assertEquals("2023-10-25T10:45:30.850", JsonDateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.85").toString());
assertEquals("2023-10-25T10:45:30.800", JsonDateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.8").toString());
assertEquals("2023-10-25T10:45:30", JsonDateTime.parseISO_LocalDateTime("2023-10-25T10:45:30").toString());
assertEquals("2023-10-25T10:45:30.851", ISODateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.851").toString());
assertEquals("2023-10-25T10:45:30.850", ISODateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.85").toString());
assertEquals("2023-10-25T10:45:30.800", ISODateTime.parseISO_LocalDateTime("2023-10-25T10:45:30.8").toString());
assertEquals("2023-10-25T10:45:30", ISODateTime.parseISO_LocalDateTime("2023-10-25T10:45:30").toString());

assertEquals("2023-10-25T10:45:30.851+02:00", JsonDateTime.parseISO_ZonedDateTime("2023-10-25T10:45:30.851+02:00").toString());
assertEquals("2023-10-25T10:45:30.851+02:00", ISODateTime.parseISO_ZonedDateTime("2023-10-25T10:45:30.851+02:00").toString());
}
}

0 comments on commit 897b361

Please sign in to comment.