com.google.gson.internal.bind.DateTypeAdapter Java Examples

The following examples show how to use com.google.gson.internal.bind.DateTypeAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlertType.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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;

}
 
Example #2
Source File: AlertType.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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;

}
 
Example #3
Source File: AlertType.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
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;

}
 
Example #4
Source File: GcmActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: GcmActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: GcmActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: GcmActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: AlertType.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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;

}
 
Example #9
Source File: AlertType.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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;

}
 
Example #10
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #12
Source File: AlertType.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #13
Source File: TransmitterData.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {//KS
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
Example #14
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #15
Source File: Calibration.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #16
Source File: Treatments.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #17
Source File: Sensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #18
Source File: AlertType.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #19
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #20
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #21
Source File: Calibration.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #22
Source File: BgReading.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #23
Source File: AppApplication.java    From AppCodeArchitecture with Apache License 2.0 5 votes vote down vote up
private void setUpApiService() {
    Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new DateTypeAdapter()).create();
    OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);
    RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint(BuildConfig.API_HOST)
            .setConverter(new GsonConverter(gson))
            .setClient(new OkClient(okHttpClient))
            .build();
    sAppApiService = restAdapter.create(AppApiService.class);
}
 
Example #24
Source File: Calibration.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #25
Source File: JsonConvertor.java    From chuck with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: UserError.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
Example #27
Source File: UserError.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();

    return gson.toJson(this);
}
 
Example #28
Source File: Calibration.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}
 
Example #29
Source File: Sensor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #30
Source File: AlertType.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public String toS() {
    Gson gson = new GsonBuilder()
            .excludeFieldsWithoutExposeAnnotation()
            .registerTypeAdapter(Date.class, new DateTypeAdapter())
            .serializeSpecialFloatingPointValues()
            .create();
    return gson.toJson(this);
}