This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This Regexp tries to grep a price from a string. | |
// 1. The number must makes sense. it may contain "." or "," i.e 1 1.000,99 10,0 etc | |
// 2. The String must conatin a currency identifier like EUR,USD,€ or $. | |
// 2a) The currency identifer may be at the begining or at the end of the matching string | |
// 2b) There may be a space between value and currency identifier | |
// This regexp is based upon http://stackoverflow.com/questions/1547574/regex-for-prices | |
(USD|EUR|€|\$|£)\s?(\d{1,}(?:[.,]\d{3})*(?:[.,]\d{2}))|(\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{2})?)\s?(USD|EUR) | |
updated Version (also matches numbers without delimiters in between like $2 $34 thx PepsiX for pointing out this issue: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twobox.evaluategson_jsonapi; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import junit.framework.TestCase; | |
import java.util.Map; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twobox.evaluategson_jsonapi.deserialize; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonObject; | |
import com.google.gson.TypeAdapter; | |
import com.google.gson.TypeAdapterFactory; | |
import com.google.gson.reflect.TypeToken; |