remove string to date converter
This commit is contained in:
parent
c7c9ed1198
commit
4e12de07ab
@ -87,5 +87,11 @@
|
|||||||
<artifactId>javax.el-api</artifactId>
|
<artifactId>javax.el-api</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
<version>1.13.1.RELEASE</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package me.chyxion.tigon.mybatis.test;
|
package me.chyxion.tigon.mybatis.test;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.chyxion.tigon.mybatis.test.model.Activity;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.repository.query.parser.Part;
|
||||||
|
import org.springframework.data.repository.query.parser.PartTree;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import javax.xml.parsers.*;
|
import javax.xml.parsers.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
import me.chyxion.tigon.mybatis.BaseMapper;
|
import me.chyxion.tigon.mybatis.BaseMapper;
|
||||||
@ -75,4 +79,19 @@ public class TestDriver {
|
|||||||
long timeElapse = System.currentTimeMillis() - timeStart;
|
long timeElapse = System.currentTimeMillis() - timeStart;
|
||||||
System.err.println("Time Elapse: " + timeElapse);
|
System.err.println("Time Elapse: " + timeElapse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParse() {
|
||||||
|
PartTree tree = new PartTree("findByIdAndHoldingDateOrderById", Activity.class);
|
||||||
|
Iterator<PartTree.OrPart> iterator = tree.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
log.info("OrPart [{}].", iterator.next());
|
||||||
|
}
|
||||||
|
for (Part part : tree.getParts()) {
|
||||||
|
System.err.println(part);
|
||||||
|
}
|
||||||
|
System.err.println(tree);
|
||||||
|
// tree = new PartTree("listByIdOrLastName", Customer.class);
|
||||||
|
// System.err.println(tree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import org.springframework.web.servlet.config.annotation.*;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||||
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
|
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||||
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
|
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
|
||||||
@ -52,8 +51,6 @@ public class TigonWebMvcConfiguration extends WebMvcConfigurationSupport {
|
|||||||
public void addFormatters(FormatterRegistry registry) {
|
public void addFormatters(FormatterRegistry registry) {
|
||||||
super.addFormatters(registry);
|
super.addFormatters(registry);
|
||||||
// converters
|
// converters
|
||||||
registry.addConverter(new StringToDateTypeConverter());
|
|
||||||
registry.addConverter(new StringToDateTypeConverter());
|
|
||||||
registry.addConverter(new StringToJSONObjectTypeConverter());
|
registry.addConverter(new StringToJSONObjectTypeConverter());
|
||||||
registry.addConverter(new StringToJSONArrayTypeConverter());
|
registry.addConverter(new StringToJSONArrayTypeConverter());
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package me.chyxion.tigon.webmvc.converter;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 0.0.1
|
|
||||||
* @author Shaun Chyxion <br>
|
|
||||||
* chyxion@163.com <br>
|
|
||||||
* Oct 19, 2015 7:45:36 PM
|
|
||||||
*/
|
|
||||||
public class StringToDateTypeConverter
|
|
||||||
implements Converter<String, Date> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Date convert(String text) {
|
|
||||||
try {
|
|
||||||
return StringUtils.isNotBlank(text) ?
|
|
||||||
new Date(Long.parseLong(text.trim())) : null;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Invalid Date [" + text + "] Param", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.web.servlet.mvc.WebContentInterceptor;
|
import org.springframework.web.servlet.mvc.WebContentInterceptor;
|
||||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||||
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
|
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||||
@ -56,8 +55,6 @@ public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter
|
|||||||
public void addFormatters(FormatterRegistry registry) {
|
public void addFormatters(FormatterRegistry registry) {
|
||||||
super.addFormatters(registry);
|
super.addFormatters(registry);
|
||||||
// converters
|
// converters
|
||||||
registry.addConverter(new StringToDateTypeConverter());
|
|
||||||
registry.addConverter(new StringToDateTypeConverter());
|
|
||||||
registry.addConverter(new StringToJSONObjectTypeConverter());
|
registry.addConverter(new StringToJSONObjectTypeConverter());
|
||||||
registry.addConverter(new StringToJSONArrayTypeConverter());
|
registry.addConverter(new StringToJSONArrayTypeConverter());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user