Search in sources :

Example 1 with SimpleDateFormat

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;
}
Also used : JndiContext(org.apache.camel.util.jndi.JndiContext) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with SimpleDateFormat

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");
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 3 with SimpleDateFormat

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");
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 4 with SimpleDateFormat

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();
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with SimpleDateFormat

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleDateFormat(java.text.SimpleDateFormat) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)2847 Date (java.util.Date)1590 ParseException (java.text.ParseException)463 DateFormat (java.text.DateFormat)425 Calendar (java.util.Calendar)307 Test (org.junit.Test)305 ArrayList (java.util.ArrayList)232 File (java.io.File)230 IOException (java.io.IOException)185 GregorianCalendar (java.util.GregorianCalendar)139 HashMap (java.util.HashMap)121 Locale (java.util.Locale)70 DateField (edu.uci.ics.textdb.api.field.DateField)64 DoubleField (edu.uci.ics.textdb.api.field.DoubleField)64 IField (edu.uci.ics.textdb.api.field.IField)64 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)64 StringField (edu.uci.ics.textdb.api.field.StringField)63 TextField (edu.uci.ics.textdb.api.field.TextField)63 Map (java.util.Map)63 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)61