Sample Code
System.debug('First Day ==> '+Date.today().toStartOfMonth());
Use the deleteWhitespace() to remove spaces from a string in Salesforce.
Ex:
String str = 'Salesforce Code Crack'; system.debug(str.deleteWhitespace());