The answer is YES
and NO
and depends on the conversion.
YES
- you can put those methods in the entity class if the conversion from one to other and vice versa is straightforward and there is no complex logic involved. Totally unrelated to this question but on similar context, kotlin has extension functions for exactly this kind of scenarios - extension function for Kotlin data class
NO
- If the conversion requires some complex logic, it is better to have it outside the entity so that it is easier to test the conversion in isolation.
Having said that, there is no right or wrong answer to your question. You can choose based on your scenario.