MCPcopy Create free account
hub / github.com/apache/pig / testGetDateTimeField

Method testGetDateTimeField

test/org/apache/pig/test/TestBuiltin.java:3159–3232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3157 }
3158
3159 @Test
3160 public void testGetDateTimeField() throws Exception {
3161 Tuple t1 = TupleFactory.getInstance().newTuple(1);
3162 t1.set(0, ToDate.extractDateTime("2010-04-15T08:11:33.020Z"));
3163 Tuple t2 = TupleFactory.getInstance().newTuple(1);
3164 t2.set(0, ToDate.extractDateTime("2010-04-15T08:11:33.020+08:00"));
3165
3166 GetYear func1 = new GetYear();
3167 Integer year = func1.exec(t1);
3168 assertEquals(year.intValue(), 2010);
3169 year = func1.exec(t2);
3170 assertEquals(year.intValue(), 2010);
3171
3172 GetMonth func2 = new GetMonth();
3173 Integer month = func2.exec(t1);
3174 assertEquals(month.intValue(), 4);
3175 month = func2.exec(t2);
3176 assertEquals(month.intValue(), 4);
3177
3178 GetDay func3 = new GetDay();
3179 Integer day = func3.exec(t1);
3180 assertEquals(day.intValue(), 15);
3181 day = func3.exec(t2);
3182 assertEquals(day.intValue(), 15);
3183
3184 GetHour func4 = new GetHour();
3185 Integer hour = func4.exec(t1);
3186 assertEquals(hour.intValue(), 8);
3187 hour = func4.exec(t2);
3188 assertEquals(hour.intValue(), 8);
3189
3190 GetMinute func5 = new GetMinute();
3191 Integer minute = func5.exec(t1);
3192 assertEquals(minute.intValue(), 11);
3193 minute = func5.exec(t2);
3194 assertEquals(minute.intValue(), 11);
3195
3196 GetSecond func6 = new GetSecond();
3197 Integer second = func6.exec(t1);
3198 assertEquals(second.intValue(), 33);
3199 second = func6.exec(t2);
3200 assertEquals(second.intValue(), 33);
3201
3202 GetMilliSecond func7 = new GetMilliSecond();
3203 Integer milli = func7.exec(t1);
3204 assertEquals(milli.intValue(), 20);
3205 milli = func7.exec(t2);
3206 assertEquals(milli.intValue(), 20);
3207
3208 GetWeekYear func8 = new GetWeekYear();
3209 Integer weekyear = func8.exec(t1);
3210 assertEquals(weekyear.intValue(), 2010);
3211 weekyear = func8.exec(t2);
3212 assertEquals(weekyear.intValue(), 2010);
3213
3214 GetWeek func9 = new GetWeek();
3215 Integer week = func9.exec(t1);
3216 assertEquals(week.intValue(), 15);

Callers

nothing calls this directly

Calls 14

getInstanceMethod · 0.95
setMethod · 0.95
extractDateTimeMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95

Tested by

no test coverage detected