类com.google.gson.internal.bind.DateTypeAdapter源码实例Demo

下面列出了怎么用com.google.gson.internal.bind.DateTypeAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xDrip   文件: AlertType.java
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit();

    return true;

}
 
源代码2 项目: xDrip   文件: AlertType.java
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit(); // always leave this as commit

    return true;

}
 
源代码3 项目: xDrip   文件: GcmActivity.java
private static String sensorAndCalibrationsToJson(Sensor sensor, int limit) {
    SensorCalibrations[] sensorCalibrations = new SensorCalibrations[1];
    sensorCalibrations[0] = new SensorCalibrations();
    sensorCalibrations[0].sensor = sensor;
    sensorCalibrations[0].calibrations = Calibration.getCalibrationsForSensor(sensor, limit);
    if (d) Log.d(TAG, "calibrations size " + sensorCalibrations[0].calibrations.size());
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    String output = gson.toJson(sensorCalibrations);
    if (d) Log.d(TAG, "sensorAndCalibrationsToJson created the string " + output);
    return output;
}
 
源代码4 项目: xDrip   文件: GcmActivity.java
private static String newCalibrationToJson(double bgValue, String uuid, long offset) {
    NewCalibration newCalibrationArray[] = new NewCalibration[1];
    NewCalibration newCalibration = new NewCalibration();
    newCalibration.bgValue = bgValue;
    newCalibration.uuid = uuid;
    newCalibration.timestamp = JoH.tsl();
    newCalibration.offset = offset;
    newCalibrationArray[0] = newCalibration;

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    String output = gson.toJson(newCalibrationArray);
    Log.d(TAG, "newCalibrationToJson Created the string " + output);
    return output;
}
 
源代码5 项目: xDrip-plus   文件: AlertType.java
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit();

    return true;

}
 
源代码6 项目: xDrip-plus   文件: AlertType.java
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit(); // always leave this as commit

    return true;

}
 
源代码7 项目: xDrip-plus   文件: GcmActivity.java
private static String sensorAndCalibrationsToJson(Sensor sensor, int limit) {
    SensorCalibrations[] sensorCalibrations = new SensorCalibrations[1];
    sensorCalibrations[0] = new SensorCalibrations();
    sensorCalibrations[0].sensor = sensor;
    sensorCalibrations[0].calibrations = Calibration.getCalibrationsForSensor(sensor, limit);
    if (d) Log.d(TAG, "calibrations size " + sensorCalibrations[0].calibrations.size());
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    String output = gson.toJson(sensorCalibrations);
    if (d) Log.d(TAG, "sensorAndCalibrationsToJson created the string " + output);
    return output;
}
 
源代码8 项目: xDrip-plus   文件: GcmActivity.java
private static String newCalibrationToJson(double bgValue, String uuid, long offset) {
    NewCalibration newCalibrationArray[] = new NewCalibration[1];
    NewCalibration newCalibration = new NewCalibration();
    newCalibration.bgValue = bgValue;
    newCalibration.uuid = uuid;
    newCalibration.timestamp = JoH.tsl();
    newCalibration.offset = offset;
    newCalibrationArray[0] = newCalibration;

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    String output = gson.toJson(newCalibrationArray);
    Log.d(TAG, "newCalibrationToJson Created the string " + output);
    return output;
}
 
源代码9 项目: xDrip-Experimental   文件: AlertType.java
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts  = new Select()
        .from(AlertType.class)
        .execute();

    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    String output =  gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit();

    return true;

}
 
源代码10 项目: chuck   文件: JsonConvertor.java
public static Gson getInstance() {
    if (gson == null) {
        gson = new GsonBuilder()
                .setPrettyPrinting()
                .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .create();
    }
    return gson;
}
 
源代码11 项目: xDrip   文件: UserError.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
源代码12 项目: xDrip   文件: Calibration.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码13 项目: xDrip   文件: Sensor.java
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    Log.d("SENSOR", "Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at);
    return gson.toJson(this);
}
 
源代码14 项目: xDrip   文件: AlertType.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码15 项目: xDrip   文件: TransmitterData.java
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
源代码16 项目: xDrip   文件: BgReading.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码17 项目: xDrip   文件: Calibration.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码18 项目: xDrip   文件: Treatments.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码19 项目: xDrip   文件: Sensor.java
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    Log.d("SENSOR", "Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at);
    return gson.toJson(this);
}
 
源代码20 项目: xDrip   文件: AlertType.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码21 项目: xDrip   文件: BgReading.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码22 项目: xDrip   文件: WatchUpdaterService.java
private synchronized void syncStepSensorData(DataMap dataMap, boolean bBenchmark) {
    Log.d(TAG, "syncStepSensorData");

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    long timeOfLastEntry = 0;
    Log.d(TAG, "syncStepSensorData add to Table");
    if (entries != null) {

        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .serializeSpecialFloatingPointValues()
                .create();

        StepCounter pm = StepCounter.last();
        Log.d(TAG, "syncStepSensorData add Table entries count=" + entries.size());
        for (DataMap entry : entries) {
            if (entry != null) {
                Log.d(TAG, "syncStepSensorData add Table entry=" + entry);
                String record = entry.getString("entry");
                if (record != null) {
                    Log.d(TAG, "syncStepSensorData add Table record=" + record);
                    StepCounter data = gson.fromJson(record, StepCounter.class);
                    if (data != null) {
                        timeOfLastEntry = (long) data.timestamp + 1;
                        Log.d(TAG, "syncStepSensorData add Entry Wear=" + data.toString());
                        Log.d(TAG, "syncStepSensorData WATCH data.metric=" + data.metric + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
                        if (!bBenchmark)
                            data.saveit();
                    }
                }
            }
        }
        sendDataReceived(DATA_ITEM_RECEIVED_PATH, "DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark ? "BM" : "STEP", -1);
    }
}
 
源代码23 项目: xDrip-plus   文件: UserError.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
源代码24 项目: xDrip-plus   文件: Calibration.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码25 项目: xDrip-plus   文件: Sensor.java
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    Log.d("SENSOR", "Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at);
    return gson.toJson(this);
}
 
源代码26 项目: xDrip-plus   文件: AlertType.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码27 项目: xDrip-plus   文件: TransmitterData.java
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
源代码28 项目: xDrip-plus   文件: BgReading.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码29 项目: xDrip-plus   文件: Calibration.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
源代码30 项目: xDrip-plus   文件: Treatments.java
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
 类所在包
 同包方法