About Salesforce
Salesforce is a cloud-based online solution for customer relationship management or CRM. Salesforce provides all of our departments like marketing, sales, commerce, and service with a shared view of our customers with a single integrated CRM platform.
Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with calls to the API. Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by Web service requests and from triggers on objects. Salesforce Apex Primitive datatypes are, Blob, Boolean, Date, DateTime, Decimal, Double, ID, Integer, Long, Object, String and Time.
Reading this article, you can learn and test the Apex primitive datatypes in SalesForce.
The prerequisites for testing Apex primitive datatypes in SalesForce as, Register a Salesforce Free Trial account using the following link.
Step 1
Log into your Salesforce Account and click the Developer Console.

Step 2
Now, we can create new Apex Class ApexDatatype and the file named as ApexDatatype.apxc,

After creating Apex class ApexDatatype,

Add a DTtest method for create and test primitive datatypes,

Step 3
The first primitive datatype is, Blob - A collection of binary data stored as a single object. For example,
- String tStr='CsharpCorner';
- Blob myBlob=blob.valueOf(tStr);
- String dStr=myBlob.toString();
- System.debug('Blob Content is : '+ dStr);
Next we have, Boolean data type- A value that can only be assigned true, false, or null.
- Boolean isRollno = true;
- System.debug('Boolean Values is : '+ isRollno);
Next we have, Date data type -A value that indicates a particular day. Unlike
Datetime values, Date values contain no information about time.
- Date todate = date.today();
- System.debug('ToDate is : '+ todate);
Next we have, DateTime data type - A value that indicates a particular day and time, such as a timestamp.
- Datetime fixdatetime=Datetime.now();
- System.debug('fixdatetime is : '+ fixdatetime);
Next we have, Decimal data type -A number that includes a decimal point. Decimal is an arbitrary precision number. Currency fields are automatically assigned the type Decimal,
- Decimal feeamount=154.70;
- System.debug('FeeAmount(Decimal) is : '+ feeamount.abs());
Next we have, Double data type -A 64-bit number that includes a decimal point.
- Double scient=154.70;
- System.debug('scient(Double) is : '+ scient);
Next we have, ID data type - Any valid 18-character Force.com record identifier.
- ID recordid='00400000003MKSBB01';
- System.debug('recordid is : '+ recordid);




Join the conversation! Your thoughts help the community grow.