Permalink
Browse files

switched back to minimal error checking

  • Loading branch information...
1 parent 0a23d08 commit d5f032815a33bfcb3c3f250534d8f86b9109ccaf Bob Briski committed Jun 18, 2012
Showing with 16 additions and 27 deletions.
  1. +16 −27 piggy/src/date_utils/TimeZoneConverter.java
@@ -22,38 +22,27 @@
* be (date, date_format, from_timezone, to_timezone)
*/
public String exec(Tuple input) throws IOException {
- try {
- if (DataChecker.isNull(input))
- return "";
-
- if (!DataChecker.isValid(input, 4))
- return "";
-
- String date = input.get(0).toString();
- String dateFormat = input.get(1).toString();
- String fromTimeZone = input.get(2).toString();
- String toTimeZone = input.get(3).toString();
- Date d = null;
-
- DateFormat df1 = new SimpleDateFormat(dateFormat);
- df1.setTimeZone(TimeZone.getTimeZone(fromTimeZone));
+ String date = input.get(0).toString();
+ String dateFormat = input.get(1).toString();
+ String fromTimeZone = input.get(2).toString();
+ String toTimeZone = input.get(3).toString();
+ Date d = null;
- try {
- d = df1.parse(date);
- } catch (Exception e) {
- warn("Could not parse date: " + date + " with format: "
- + dateFormat, PigWarning.UDF_WARNING_1);
- return "";
- }
+ DateFormat df1 = new SimpleDateFormat(dateFormat);
+ df1.setTimeZone(TimeZone.getTimeZone(fromTimeZone));
- DateFormat df2 = new SimpleDateFormat(dateFormat);
- df2.setTimeZone(TimeZone.getTimeZone(toTimeZone));
-
- return df2.format(d);
+ try {
+ d = df1.parse(date);
} catch (Exception e) {
- warn("Exception " + e.getMessage(), PigWarning.UDF_WARNING_1);
+ warn("Could not parse date: " + date + " with format: "
+ + dateFormat, PigWarning.UDF_WARNING_1);
return "";
}
+
+ DateFormat df2 = new SimpleDateFormat(dateFormat);
+ df2.setTimeZone(TimeZone.getTimeZone(toTimeZone));
+
+ return df2.format(d);
}
public Schema outputSchema(Schema input) {

0 comments on commit d5f0328

Please sign in to comment.