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
public class DateDeserializer implements JsonDeserializer<MyDate> { | |
//if not epoch time from server response | |
public static SimpleDateFormat serverFormatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'"); | |
public static SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); | |
@Override | |
public MyDate deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) throws JsonParseException { | |
String date = element.getAsString(); | |
//if epoch sent then create date object directly new Date(time*1000) | |
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));//the timezones you want |
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
if (throwable instanceof HttpException) { | |
Response response = ((HttpException) throwable).response(); | |
RetrofitError commonResponse = null; | |
if (response != null) { | |
Gson gson = new Gson(); | |
try { | |
commonResponse = gson.fromJson(response.errorBody().string(), RetrofitError.class); | |
CommonUtilities.showAlertDialog(context, commonResponse.getMessage()); | |
} catch (IOException e) { | |
e.printStackTrace(); |
NewerOlder