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

Message Edited by bca321 on 03-04-2009 04:27 AM
Message Edited by bca321 on 03-04-2009 05:01 AM
mikefmikef

Try using a 4 digit year, and 2 digit month.

Jan = 01.

bca321bca321
Message Edited by bca321 on 03-04-2009 04:27 AM
mikefmikef

Returns a Date that contains the value of the specified String.The String should use the standard date format "yyyy-MM-dd HH:mm:ss" in the local time zone. For example: stringyear='2008'; stringmonth='10'; stringday='5'; stringhour='12'; stringminute='20'; stringsecond='20'; stringstringDate=year+'-'+month +'-'+day+''+hour+':'+ minute+':'+second; DatemyDate=date.valueOf(stringDate);

 

this is straight from the docs.
bca321bca321
Message Edited by bca321 on 03-04-2009 04:27 AM
mikefmikef

Apex doesn't support any date format other then what is in the docs.

You will need to write your own class that parses out the date and can return the format you want.

bca321bca321

Can u pl's explain me how to do that.

Ex: 09 Jan 17

mikefmikef

Create a class that will manipulate the date so you can return any number of formats.

 

 

global class DateFormater{ private Date theDate; private static List<String> monthList = new List<String>({'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}); public DateFormater(Date theDate){ this.theDate = theDate;

} public String customDate(){ String y = String.valueOf(this.theDate.year()); Integer m = this.theDate.month(); String d = String.valueOf(this.theDate.day()); return y.substring(2) + ' ' + DateFormater.monthList[m - 1] + ' ' + d; } }

 

You would call your new class like this.

 

 

DateFormater df = new DateFormater(date); String myString = df.customDate();

 

 Please note I have not compiled this code and have no idea if it will work, but it will get you started.

 

You can keep adding to your DateFormater class to support different formats that you want to have.

 

 

 

bca321bca321
Message Edited by bca321 on 03-04-2009 04:26 AM
mikefmikef

why are you making webservices?

I am not sure I follow the scope of your project?

What is the use case you are trying to solve here?