Skip to content

Commit

Permalink
New MapUtils.getMapDouble/getMapFloat methods
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Sep 6, 2016
1 parent acc6a07 commit 2892e26
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ public static long getMapLong(final Map<?, ?> map, final String key, long defaul
}
}

public static float getMapFloat(final Map<?, ?> map, final String key) {
return getMapFloat(map, key, 0);
}
public static float getMapFloat(final Map<?, ?> map, final String key, long defaultValue) {
try {
return Float.parseFloat(getMapStr(map, key));
} catch (NumberFormatException e) {
return defaultValue;
}
}

public static double getMapDouble(final Map<?, ?> map, final String key) {
return getMapDouble(map, key, 0);
}
public static double getMapDouble(final Map<?, ?> map, final String key, long defaultValue) {
try {
return Double.parseDouble(getMapStr(map, key));
} catch (NumberFormatException e) {
return defaultValue;
}
}

/*
* returns a date object from the passed key in the passed map
* returns null if key doesn't exist or isn't a date
Expand Down

0 comments on commit 2892e26

Please sign in to comment.