[
https://issues.apache.org/jira/browse/METRON-1816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16654078#comment-16654078
]
ASF GitHub Bot commented on METRON-1816:
----------------------------------------
Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/metron/pull/1233#discussion_r226064248
--- Diff:
metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/DateFunctionsTest.java
---
@@ -225,4 +226,36 @@ public void testDayOfYearNow() {
public void testDayOfYearNull() {
Object result = run("DAY_OF_YEAR(nada)");
}
+
+ @Test
+ public void testDateFormat() {
+ Object result = run("DATE_FORMAT('EEE MMM dd yyyy hh:mm:ss zzz',
epoch, 'EST')");
+ assertEquals("Thu Aug 25 2016 08:27:10 EST", result);
+ }
+
+ @Test
+ public void testDateFormatDefault() {
+ Object result = run("DATE_FORMAT('EEE MMM dd yyyy hh:mm:ss zzzz')");
+
assertTrue(result.toString().endsWith(TimeZone.getDefault().getDisplayName(true,
1)));
+ }
+
+ @Test
+ public void testDateFormatNow() {
+ Object result = run("DATE_FORMAT('EEE MMM dd yyyy hh:mm:ss zzz',
'GMT')");
+ assertTrue(result.toString().endsWith("GMT"));
+ }
+
+ @Test
+ public void testDateFormatDefaultTimezone() {
+ Object result = run("DATE_FORMAT('EEE MMM dd yyyy hh:mm:ss zzzz',
epoch)");
+
assertTrue(result.toString().endsWith(TimeZone.getDefault().getDisplayName(true,
1)));
+ }
+
+ /**
+ * If refer to variable that does not exist, expect ParseException.
+ */
+ @Test(expected = ParseException.class)
+ public void testDateFormatNull() {
+ Object result = run("DATE_FORMAT('EEE MMM dd yyyy hh:mm:ss zzz', nada,
'EST')");
+ }
--- End diff --
Can we have a test for an invalid format
> Date format Stellar function
> ----------------------------
>
> Key: METRON-1816
> URL: https://issues.apache.org/jira/browse/METRON-1816
> Project: Metron
> Issue Type: Improvement
> Reporter: Ryan Merriman
> Priority: Major
>
> It would be useful to have a Stellar function that exposes the Java
> SimpleDateFormat capability. This will allow us to correctly format date
> fields for storage platforms that require a specific date format (Solr for
> example).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)