57

This will print the date out in the format December 14, 2013. The documentation can be found here <apex:outputText value="{0, date, MMMM d',' yyyy}"> <apex:param value="{!contact.Birthdate}" /> </apex:outputText> or if all you need is the current date printed out in that format then you can use this: <apex:outputText value="{0, ...


19

DateTime dt = DateTime.now(); String formattedDt = dt.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\''); Update: Another option is to use SOQL dynamic binding, no formatting required. DateTime dt = DateTime.now(); String query = 'SELECT Id FROM User WHERE SystemModstamp > :dt ' List<SObject> results = Database.query(query);


12

Yes it is odd that the format strings are not interpreted in a locale sensitive way, i can only assume its due to the Java thread not being set to the users locale internally. There are two ways to approach this problem. Both approaches could be used directly in a controller with custom bindings or wrapped for reuse in a Visualforce Component, as per this ...


11

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!contact.Birthdate}" /> </apex:outputText> link to full doc: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm


10

Prettier by design does not really allow customization of the formatting, this is why it is an "Opinionated Source Formatter". For Apex, your formatting options are limited to the following configuration settings: printWidth tabWidth useTab https://github.com/dangmai/prettier-plugin-apex Source to be formatted: public with sharing class Controller { ...


9

Here ya go for everyone needing to know this. Here's how it is done: <p id="date" style="font-family:Georgia, serif; color:#446c5a; font-style:italic; font-size:16px; padding-top:0px; margin-bottom:0;">%%xtmonth%% %%xtday%%, %%xtyear%%</p> %%[Var @curdate, @url SET @curdate = Format(Now(), "MMddyyyy") SET @url = Concat("http://...


8

I don't have enough reputation to writes comment. Therefore I have to put them into this answer: Comment to Andrew Fawcett's answer The first part of his post "Dynamically Generating your Format String" works only in locales where comma and point are the thousands separator and decimal separator, because DynamicFormatString in apex:outputText ...


7

The format method automatically does the commas and periods or visa versa (depending on whether your profile is in the US or elsewhere) Assuming the $ sign applies to all cases in your org you can simply use Decimal input = 2000; String output = '$' + String.valueOf(input.format()); Note the String.valueOf(). This is required because the input variable is ...


6

I'm using astyle. You can install in in sublimetext via package install.


6

The <apex:outputText> can be formatted along with <apex:param>. <apex:outputText value="{0, number, $#,###.##}"> <apex:param value="{!Goal__c.Quarterly_Goal__c}"/> </apex:outputText> Hope it helps.


5

Follow this. You have to override the html formatter with lwc as parser - note that it will not retrospectively "fix" your markup which means the quotes will stay but at least it should not add them after reformatting again


5

You can access the user's locale via the i18n library methods, which you can then pass in to LWC datatable's typeAttributes: import USERLOCALCURRENCY from '@salesforce/i18n/currency'; ... { label: 'Amount', fieldName: 'amount', type: 'currency', typeAttributes: { currencyCode: USERLOCALECURRENCY }},


5

@keith-c, thank you for your question. I work at Salesforce, and reviewed the component, and the documentation along with a colleague on the Docs team. If you are setting the attribute time-zone="UTC" on lightning-formatted-date-time, you shouldn't see the day value change, no matter which time zone setting is being retrieved by the component. If ...


4

While Ralph Callaway's example is technically correct, it can be simplified. There is no need for conditional rendering of the <apex:outputText> elements, or multiplying the value by -1. Instead we can use a subpattern for the negative number format. From Java docs: A DecimalFormat pattern contains a positive and negative subpattern, for example, "...


4

If you need to use an ActionRegion, you need to restructure your page, using a pageBlockSectionItem You'll need something like this: <apex:pageBlockSection title="Data Section" collapsible="false"> <apex:pageBlockSectionItem> <apex:outputLabel value="{!$ObjectType.myobject__c.fields.Tester__c.label}" for="testerField"/> <...


4

I suspect you are dealing with a Timezone Daylight Savings Time transition in the (GMT-07:00) Pacific Daylight Time (America/Tijuana) Timezone (Pacific) that occurs in that date range. On Sunday the 2nd of November they will transition from PDT to PST. Source So they will go from UTC-7h to UTC-8h. The DateTime.month() and format() for DateTime will be ...


4

According to the Docs.... Reference Can't you just wrap set your specific fields you want to disable? IE: <apex:outputField value="{!contact.firstname}"> <apex:inlineEditSupport disabled="false"/> </apex:outputField> <apex:outputField value="{!contact.lastname}"> <apex:inlineEditSupport ...


4

you can achieve it by replacing the Z with XXX. Datetime sdf = Datetime.now(); system.debug(sdf.format('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX')); The result was: 2015-05-20T20:28:23.203+02:00 This is documented here


4

You can use the Java Message Format that is built into the outPutText tag: https://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html It would go like this (having a number in the tens, teeth's, and hundredths at all times (0): <apex:outPutText value="{0,number,#,##0.00}"> <apex:param value="{!FIELDAPINAME}"/> </apex:...


4

Just change: MM/dd/yyyy to: M/d/yyyy


4

One small change required, declare the apex:param tag inside the apex:outputText. <apex:column> <apex:facet name="header">AUM</apex:facet> <apex:outputText value="{0, Number, Currency}" > <apex:param value="{!product.AUMString}" /> </apex:outputText> </apex:column>


4

You are on the right track that you need to pass in a specific format string to Datetime.now().format(...). Notice how you escape the T in your current format: Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ') Just do the same thing with the Z: Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'') Note that Z is a valid argument in ...


4

After running the install command: npm install --save-dev --save-exact prettier prettier-plugin-apex Restart VS Code. Then, go to View > Command Palette... and find the command "Prettier: Create Configuration File", and run it. Finally, you can go to the .prettierrc file in your project's root folder, open it up, and set either the number of spaces to ...


4

YYYY is week based calendar. yyyy is our ordinary calender. This is not SF behavior. but something expected whenever you use yyyy or YYYY as they are derived from java SimpleDateFormat. Even SF document points to refer SimpleDateFormat. Here is an excellent blog post showing this behaviour.


3

This should work, if its until 2 decimals: Decimal dec; String amount; if (!string.valueof(dec.format()).right(3).contains('.')){ amount = '$' + string.valueof(dec.format()) + '.00'; }else if (string.valueof(dec.format()).right(2).contains('.')){ amount = '$' + string.valueof(dec.format()) + '0'; }else { amount = '$' + string.valueof(dec.format()...


3

String.format() seems to accept only Strings as arguments, it's less powerful than apex:outputText. Check the @Abhinav's blog post at http://www.tgerm.com/2011/01/message-format-string-format-apex.html, vote for his idea... I think for now your best choice is this: Decimal x = 123456789.01; System.debug(x.format()); It outputs 123,456,789.01 in my ...


3

To use the Salesforce datepicker on an input field: <apex:page> <apex:form> <apex:inputText size="10" id="datefield" onfocus="DatePicker.pickDate(true, this, false);" /> </apex:form> </apex:page> You will need to use API Version 29.0 on your VF page though.


3

It's actually a Date value, so you can call normal Date methods on it. Use a locale-safe option that respects month/day and day/month output by having the browser figure it out for you: var dateString = result.dateValue.toLocaleDateString();


3

Here is an outline of a solution (for dates and datetimes). Other data types I leave as an exercise for the reader You'll need a VF Component Controller public with sharing class UserLocale { public Object valueToDisplayInLocale {get; set;} public String localePattern { get { if (this.valueToDisplayInLocale instanceof Date) ...


3

You could do something like this: %%[ set @twoMonthsDate = dateadd(now(), 2, "M") set @month = DatePart(@twoMonthsDate, "M") set @year = DatePart(@twoMonthsDate, "Y") set @firstOfTwoMonthsDate = dateparse(concat(@month,"/01/",@year)) set @lastDayNextMonth = dateadd(@firstOfTwoMonthsDate,-1,"D") ]%% <br>now(): %%=now()=%% <br>@twoMonthsDate: %%=...


Only top voted, non community-wiki answers of a minimum length are eligible