我有一个用泽西开发的休息服务,我有一个ContainerRequestFilters用于打印请求,如下:
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
我使用log4j记录了post方法.但LoggingFilter在日志中打印的log4j不同.LogginFilter有没有办法使用log4j的配置?
我在log4j.xml文件中尝试过这个:
<logger name="com.sun.jersey.api.container.filter.LoggingFilter">
<level value="info" />
<appender-ref ref="ROOT" />
<appender-ref ref="CONSOLE" />
</logger>
Run Code Online (Sandbox Code Playgroud)
但它不起作用:(
我有这样的集合:
{
"_id" : ObjectId("963fae9d93f4d930c98e269d"),
"myDate":ISODate("2017-02-05T05:00:00.000Z"),
"otherData":"blablabla"
},
{
"_id" : ObjectId("963fae9d93f4d930c98e269d"),
"myDate":ISODate("2017-02-05T14:00:00.000Z"),
"otherData":"blablabla"
},
{
"_id" : ObjectId("963fae9d93f4d930c98e269d"),
"myDate":ISODate("2017-03-05T02:00:00.000Z"),
"otherData":"blablabla"
},
{
"_id" : ObjectId("963fae9d93f4d930c98e269d"),
"myDate":ISODate("2017-03-05T19:00:00.000Z"),
"otherData":"blablabla"
}
Run Code Online (Sandbox Code Playgroud)
给定当前日期(分钟和秒),我想找到最接近当前日期的记录(通过"myDate"字段).
谢谢
我有一个Document(org.w3c.dom.Document),我将这个文件转换为byte数组:
private byte[] obtenerBytesDeDocument(Document documentoXml) throws Exception {
Source source = new DOMSource( documentoXml );
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result result = new StreamResult(out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.transform(source, result);
byte[] butesXml = out.toByteArray();
return butesXml;
}
Run Code Online (Sandbox Code Playgroud)
我需要将byte的数组转换为新文档:
private Document obtenerDocumentDeByte(byte[] documentoXml) throws Exception {
...
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?
Thansks!
我收到一个表示日期的字符串,我需要将此字符串转换为日期,并验证字符串是否为有效日期.
我收到字符串33-12-2013一个解析方法返回日期01-01-2014,代码:
Date fechaVencimientoFormateada;
SimpleDateFormat formateador = new SimpleDateFormat( "dd-MM-yyyy" );
try
{
fechaVencimientoFormateada = formateador.parse( "33-12-2013" );
System.out.println( formateador.format(fechaVencimientoFormateada) );
}
catch ( ParseException e )
{
System.out.println("ERROR!");
}
Run Code Online (Sandbox Code Playgroud)
输出:2014年1月2日00:00:00 COT 2014
我期待一个ParseException,任何想法?
和其他例子:
字符串日期:365-12-2013输出:Sun Nov 30 00:00:00 COT 2014
字符串日期:1-24-2013输出:2014年12月1日00:00:00 COT 2014
为什么ParseException不抛?