title: Android Room TypeConverter for Double
body: <p>I am trying to use custom TypeConverter for Android Room Persistance Library as shown in <a href="https://developer.android.com/reference/android/arch/persistence/room/TypeConverter.html" rel="nofollow noreferrer">documentation</a>. Main idea is to format all Sqlite SUM selects that Android Room Dao is preforming.</p>
  
  <p>My code:</p>
  
  <pre><code> @TypeConverter
  public static double toDouble(String str) {
      return FormatHelper.formatAmount(Double.parseDouble(str));
  }
  
  @TypeConverter
  public static String fromDouble(double doub) {
      return String.valueOf(FormatHelper.formatAmount(doub));
  }
  </code></pre>
  
  <p>I already tried to clear data and rebuild the app. 
  Converters for Date in the same class are working.
  Does the Android TypeConverters not supports Primitive variables? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I register TypeConverter in RoomDatabase class so it is used across whole database.</p>
  
  <p>More specifically about my problem: if I have Query in my Dao class like this: </p>
  
  <pre><code>@Query("SELECT SUM(quantity) FROM production_plan_item")
  Double getActivePlanItemsCount();
  </code></pre>
  
  <p>It may sometimes return value like 2.30000000000001.</p>
  
  <p>I thought that Type converters are used to process returned value of queries. And every time before I save double to database or select double from it, my TypeConverter would round the double for me and I would not have to round it every time I select something.</p>
  
  <p>Otherwise I have to round every single selected double manually. </p>