Return-Path: X-Original-To: apmail-streams-dev-archive@minotaur.apache.org Delivered-To: apmail-streams-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 317A8179B0 for ; Fri, 7 Nov 2014 17:36:47 +0000 (UTC) Received: (qmail 66285 invoked by uid 500); 7 Nov 2014 17:36:47 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 66245 invoked by uid 500); 7 Nov 2014 17:36:47 -0000 Mailing-List: contact dev-help@streams.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streams.incubator.apache.org Delivered-To: mailing list dev@streams.incubator.apache.org Received: (qmail 66234 invoked by uid 99); 7 Nov 2014 17:36:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Nov 2014 17:36:46 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of steve@blackmon.org designates 209.85.160.170 as permitted sender) Received: from [209.85.160.170] (HELO mail-yk0-f170.google.com) (209.85.160.170) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Nov 2014 17:36:41 +0000 Received: by mail-yk0-f170.google.com with SMTP id 19so2480970ykq.15 for ; Fri, 07 Nov 2014 09:35:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=hOpYj91IdRvLB0+Ar2zdgoqGmGSEUVCJZCxwxki7LRA=; b=mA0wDZjXlt84hb8oXPQB1tT8uP1XlwV8gagw4YR3/8ek1BeWZRO3GxWuoUW69EgZ75 bbPC4ge8QkJ4oWtLJ452qhDBdi1YnTtSGOaE7/HRxJOFaaTjlS17B5gZdNKhd/hMFKX0 amOApfD9ligial0GlhvjOELG7EtAMnRVzdqkohKDeBG6j41fV/fJo4VJJCK4n6k4qMxy NbzodLsbJB5W9i95XcIxo27d5aP70yWY0vrAGbAGC7lTqcJUJdykqVFT0QFe7FA3dVIA W4O5Mqo7qb3WaDpYQH23lBnFbTETaZGBsrf+6pxeNw4N5aVsXAGm/1cVentaWF7m+F7P Ul0w== X-Gm-Message-State: ALoCoQksfHFqCXvBMqENucHS03qif/Z++zO70anoDj72rYRaGFwIZNmtupEOYwvea/6g7AqaZxP8 MIME-Version: 1.0 X-Received: by 10.170.202.196 with SMTP id t187mr14062474yke.36.1415381735313; Fri, 07 Nov 2014 09:35:35 -0800 (PST) Received: by 10.170.126.5 with HTTP; Fri, 7 Nov 2014 09:35:35 -0800 (PST) X-Originating-IP: [166.176.56.179] Received: by 10.170.126.5 with HTTP; Fri, 7 Nov 2014 09:35:35 -0800 (PST) In-Reply-To: <20141107155905.6531B989DE6@tyr.zones.apache.org> References: <20141107155905.6531B989DE6@tyr.zones.apache.org> Date: Fri, 7 Nov 2014 11:35:35 -0600 Message-ID: Subject: Re: [GitHub] incubator-streams pull request: adds arbitrary Joda format support... From: Steve Blackmon To: dev@streams.incubator.apache.org Content-Type: multipart/alternative; boundary=001a1139d06a8e2cc70507483d05 X-Virus-Checked: Checked by ClamAV on apache.org --001a1139d06a8e2cc70507483d05 Content-Type: text/plain; charset=UTF-8 Yes. On Nov 7, 2014 8:01 AM, "robdouglas" wrote: > Github user robdouglas commented on a diff in the pull request: > > > https://github.com/apache/incubator-streams/pull/120#discussion_r20018054 > > --- Diff: > streams-pojo/src/main/java/org/apache/streams/jackson/StreamsDateTimeDeserializer.java > --- > @@ -21,23 +21,44 @@ > import com.fasterxml.jackson.core.JsonParser; > import com.fasterxml.jackson.databind.DeserializationContext; > import com.fasterxml.jackson.databind.deser.std.StdDeserializer; > +import com.google.common.collect.Lists; > import org.apache.streams.data.util.RFC3339Utils; > import org.joda.time.DateTime; > +import org.joda.time.format.DateTimeFormat; > +import org.joda.time.format.DateTimeFormatter; > > import java.io.IOException; > import java.io.Serializable; > +import java.util.ArrayList; > +import java.util.Iterator; > +import java.util.List; > > /** > * Created by sblackmon on 3/27/14. > */ > public class StreamsDateTimeDeserializer extends > StdDeserializer implements Serializable { > > + List formatters = Lists.newArrayList(); > + > protected StreamsDateTimeDeserializer(Class > dateTimeClass) { > super(dateTimeClass); > } > > + protected StreamsDateTimeDeserializer(Class > dateTimeClass, List formats) { > + super(dateTimeClass); > + for( String format : formats ) > + formatters.add(DateTimeFormat.forPattern(format)); > + } > + > @Override > public DateTime deserialize(JsonParser jpar, > DeserializationContext context) throws IOException { > - return > RFC3339Utils.getInstance().parseToUTC(jpar.getValueAsString()); > + > + DateTime result = > RFC3339Utils.parseToUTC(jpar.getValueAsString()); > --- End diff -- > > Are the formatters here essentially meant as fall backs in case the > RFC3339Utils class isn't able to parse the date? > > > --- > If your project is set up for it, you can reply to this email and have your > reply appear on GitHub as well. If your project does not have this feature > enabled and wishes so, or if the feature is enabled but not working, please > contact infrastructure at infrastructure@apache.org or file a JIRA ticket > with INFRA. > --- > --001a1139d06a8e2cc70507483d05--