/QingTingFanBianYi/src/com/alibaba/fastjson/parser/deserializer/TimestampDeserializer.java

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 53 lines · 44 code · 5 blank · 4 comment · 7 complexity · 07a3749eea1595fa67e2133d385eac6b MD5 · raw file

  1. package com.alibaba.fastjson.parser.deserializer;
  2. import com.alibaba.fastjson.JSONException;
  3. import com.alibaba.fastjson.parser.DefaultJSONParser;
  4. import java.lang.reflect.Type;
  5. import java.sql.Timestamp;
  6. import java.text.DateFormat;
  7. import java.text.ParseException;
  8. import java.util.Date;
  9. public class TimestampDeserializer extends AbstractDateDeserializer
  10. implements ObjectDeserializer
  11. {
  12. public static final TimestampDeserializer instance = new TimestampDeserializer();
  13. protected <T> T cast(DefaultJSONParser paramDefaultJSONParser, Type paramType, Object paramObject1, Object paramObject2)
  14. {
  15. if (paramObject2 == null);
  16. do
  17. {
  18. return null;
  19. if ((paramObject2 instanceof Date))
  20. return new Timestamp(((Date)paramObject2).getTime());
  21. if ((paramObject2 instanceof Number))
  22. return new Timestamp(((Number)paramObject2).longValue());
  23. if (!(paramObject2 instanceof String))
  24. break;
  25. paramType = (String)paramObject2;
  26. }
  27. while (paramType.length() == 0);
  28. paramDefaultJSONParser = paramDefaultJSONParser.getDateFormat();
  29. try
  30. {
  31. paramDefaultJSONParser = new Timestamp(paramDefaultJSONParser.parse(paramType).getTime());
  32. return paramDefaultJSONParser;
  33. }
  34. catch (ParseException paramDefaultJSONParser)
  35. {
  36. return new Timestamp(Long.parseLong(paramType));
  37. }
  38. throw new JSONException("parse error");
  39. }
  40. public int getFastMatchToken()
  41. {
  42. return 2;
  43. }
  44. }
  45. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  46. * Qualified Name: com.alibaba.fastjson.parser.deserializer.TimestampDeserializer
  47. * JD-Core Version: 0.6.2
  48. */