Free computer code on screen

How to retrieve domain name from Salesforce org

Select Domain FROM domain

The Domain object is related to Site.com, which will not return org domain.

So what is workaround? Here is below code snippet.

String myDomain = Url.getSalesforceBaseUrl().getHost();