function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bca321bca321 

Apex code error

Hi,

 

My date field type is Date. date patern is yy-mm-dd.

 

String year = '';

String month = '';String day =

'';string stringDate = year + '' + month + '' + day;

Date DueDate = date.valueOf(stringDate);

 

my code is here. but still error. can you pl's tel me how to write code. and also I want to write regular expression for that date field.

ShikibuShikibu
The code you pasted in seems to be broken. Perhaps you can be a little clearer?

You can learn about regular expressions on this page of the Apex manual.
 
A regexp for yy-mm-dd might look like: '\d\d-\d\d-\d\d'
 
 
bca321bca321

Hi,

 

Here the code sample,

 

String year = '';

String month = '';

String day = '';

String StringDate = year + '' + month + '' + day;

Date DueDate = date.valueOf(stringDate);

ShikibuShikibu

Perhaps you could benefit from a bit more time studying the manual and experimenting with execute anonymous. The docs for the method valueOf for the class date say it works like this:

 

 

The String should use the standard date format "yyyy-MM-dd HH:mm:ss" in the local time zone. For example:

string year = '2008';
string month = '10';
string day = '5';
string hour = '12';
string minute = '20';
string second = '20';
string stringDate = year + '-' + month
+ '-' + day + ' ' + hour + ':' +
minute + ':' + second;

Date myDate = date.valueOf(stringDate);

 

 

 

bca321bca321

for decimal type what is the regular expresion

 

ex; Desimal amount;

45678.00

 

for Double type  what is regular expression

 

ex: double number

 

234