use of java.text.SimpleDateFormat in project camel by apache.
the class AtomEntryPollingConsumerTest method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
JndiContext jndi = new JndiContext();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
jndi.bind("myDate", df.parse("2007-11-13 14:35:00 +0100"));
return jndi;
}
use of java.text.SimpleDateFormat in project camel by apache.
the class FtpProducerExpressionTest method testProducerDateByExpression.
@Test
public void testProducerDateByExpression() throws Exception {
template.sendBody(getFtpUrl() + "&fileName=myfile-${date:now:yyyyMMdd}.txt", "Hello World");
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
assertFileExists(FTP_ROOT_DIR + "/filelanguage/myfile-" + date + ".txt");
}
use of java.text.SimpleDateFormat in project camel by apache.
the class FtpProducerExpressionTest method testProducerDateByHeader.
@Test
public void testProducerDateByHeader() throws Exception {
sendFile(getFtpUrl(), "Hello World", "myfile-${date:now:yyyyMMdd}.txt");
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
assertFileExists(FTP_ROOT_DIR + "/filelanguage/myfile-" + date + ".txt");
}
use of java.text.SimpleDateFormat in project camel by apache.
the class DefaultBacklogTracerEventMessage method toXml.
/**
* Dumps the event message as XML using the {@link #ROOT_TAG} as root tag.
* <p/>
* The <tt>timestamp</tt> tag is formatted in the format defined by {@link #TIMESTAMP_FORMAT}
*
* @return xml representation of this event
*/
public String toXml(int indent) {
StringBuilder prefix = new StringBuilder();
for (int i = 0; i < indent; i++) {
prefix.append(" ");
}
StringBuilder sb = new StringBuilder();
sb.append(prefix).append("<").append(ROOT_TAG).append(">\n");
sb.append(prefix).append(" <uid>").append(uid).append("</uid>\n");
String ts = new SimpleDateFormat(TIMESTAMP_FORMAT).format(timestamp);
sb.append(prefix).append(" <timestamp>").append(ts).append("</timestamp>\n");
// route id is optional and we then use an empty value for no route id
sb.append(prefix).append(" <routeId>").append(routeId != null ? routeId : "").append("</routeId>\n");
if (toNode != null) {
sb.append(prefix).append(" <toNode>").append(toNode).append("</toNode>\n");
} else {
// if first message the use routeId as toNode
sb.append(prefix).append(" <toNode>").append(routeId).append("</toNode>\n");
}
sb.append(prefix).append(" <exchangeId>").append(exchangeId).append("</exchangeId>\n");
sb.append(prefix).append(messageAsXml).append("\n");
sb.append(prefix).append("</").append(ROOT_TAG).append(">");
return sb.toString();
}
use of java.text.SimpleDateFormat in project camel by apache.
the class TimerWithTimeOptionTest method testFiredInFutureCustomPattern.
public void testFiredInFutureCustomPattern() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
Date future = new Date(new Date().getTime() + 1000);
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String time = sdf.format(future);
fromF("timer://foo?time=%s&pattern=dd-MM-yyyy HH:mm:ss", time).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
// period is default 1000 so we can get more messages
mock.expectedMinimumMessageCount(1);
assertMockEndpointsSatisfied();
}
Aggregations