Skip to main content
17 votes
Accepted

How To Format Datetime like 2017-01-10T14:53:55.000+0000?

Using the example given in the DateTime class and calling the formatGMT(string) method with a formatting string found in the Java SimpleDateFormat examples: DateTime myDateTime = DateTime.newInstance(...
Mark Pond's user avatar
  • 23k
16 votes

Format APEX code Visual Studio code

You can use uncrustify with VS Code. You need to install the code on your platform (http://uncrustify.sourceforge.net/), and then search for "uncrustify" in VS Code Extensions. Next, be sure to add ...
Vernon Keenan's user avatar
12 votes

Format APEX code Visual Studio code

To make this easier, I have documented the Uncrustify steps that got this working for me on Mac OSX with VSCode: Install Uncrustify binaries with brew: > brew install uncrustify In VSCode, go to ...
Shanerk's user avatar
  • 1,076
11 votes

Format APEX code Visual Studio code

I assume that OP means the part of VS Code that determines standard formatting for Apex files. If you have Salesforce Extensions installed, typing SHIFT+ALT+F will give an error message: There is ...
frackham's user avatar
  • 431
10 votes
Accepted

Format APEX code Visual Studio code

Personally, I use the following extensions for vscode: Salesforce Extensions for VS Code - A package of Salesforce made extensions for editing code. Provides syntax highlighting & will recognize ...
battery.cord's user avatar
  • 8,845
9 votes
Accepted

Format date as two digit month and day

Only the Datetime type has a format method that lets you specify what format to use (instead of just the locale default). Likely that is because SimpleDateFormat supports many time components in ...
Adrian Larson's user avatar
  • 151k
9 votes

What are the minimum and maximum valid dates in Salesforce?

Initially I have found an answer here, but the link provided in that answer, was broken. Finally found a corresponding valid link in the documentation Minimum and Maximum Dates Only dates ...
Patlatus's user avatar
  • 17.2k
7 votes

UPPER case in lightning component

You make the text as uppercase by using text-transform:uppercase css. More info on text-transform can be found here <div> <a style="text-transform:uppercase" data-record="{!record.Id}" ...
Praveen's user avatar
  • 10.1k
7 votes

Accessing Multiple Fields From a SOQL Query Using FORMAT()

It looks to me that this FORMAT() documentation fails to mention that the formatted value can only be obtained using a get of the alias. This produces the expected result for the formatted values and ...
Keith C's user avatar
  • 136k
7 votes

How to remove time from date?

only way I found is to keep the date format and remove the 00 from end System.debug('Current date: ' + String.valueOf(Date.today()).removeEnd(' 00:00:00'));
Ratan Paul's user avatar
  • 22.7k
6 votes
Accepted

Datetime.format('yyyy-MM-dd') subtracts a day

mplax, when you create the date via Date.newInstance it is creating the 1st of dec as per GMT. Once you call format on it. It applies your locale settings which would not be as GMT and your timezone ...
Kiran Machhewar's user avatar
6 votes
Accepted

FORMATDATE and format pattern to add year when using format pattern "M"

To provide it as answer (even though i might not be worth it): You have to do the following FORMATDATE(@START_DT,"D. MMMM YYYY","","da-DK") You can set delimeters like you want in these format ...
Johannes Schapdick's user avatar
5 votes

Linting tools for legacy apex repo

While there are commercial tools in this space, I'd start with Apex PMD. It's free and open source, and there's an excellent plugin for Visual Studio Code to run it right in the IDE. There's also an ...
David Reed's user avatar
  • 93.2k
4 votes

Decimal formatted number in APEX

Seems easy enough Decimal with a precision of 6 Decimal d = 123456; Add a 0 in front String t = 0 + string.valueOf(d); Per your requirements but I suspect what you want is this (modified with ...
Eric's user avatar
  • 54.2k
4 votes

Format APEX code Visual Studio code

I didn't want to use Crustify, which most of the other answers suggested. However, I came across the following for sfdx and VS Code. It is prettier, with a (possibly community contributed) Apex plugin:...
bpilling's user avatar
  • 670
4 votes

Format APEX code Visual Studio code

Here there is a guide to how indent Apex in Visual Studio Code https://mrwolf.altervista.org/how-to-indent-apex-code-in-visual-studio-code/ Simply, it's needed to install uncrustify plugin on visual ...
Pasquale Napolitano's user avatar
4 votes
Accepted

Where i need to change the format of date and currency for german locale

2.045 is actually the correct format for the German locale. Much of Europe (and much of the rest of the world, for that matter) uses the period/full-stop as the digit grouping separator, and a comma ...
Derek F's user avatar
  • 62.7k
3 votes
Accepted

The $Locale global value provider returns wrong datetimeFormat value

The documentation is pretty clear (imo) on this one, The framework’s number and date formatting are based on Java’s DecimalFormat and DateFormat classes. and the format sample in it: "MMM d, ...
glls's user avatar
  • 20.2k
3 votes
Accepted

how to convert string(text) to number(integer) in vf page

For converting the text to number in Visualforce merge fields, you can use VALUE function in merge fields If you have property with name division, you can use following code for Visualforce: {!VALUE(...
Raul's user avatar
  • 18.8k
3 votes
Accepted

Fields of Attributes with Data Type Date are not in accordance with the Date format

Regardless of any settings you put on the business unit, all dates stored in a data extension follow the below rule: All dates are stored in the 12-hour format of MM/DD/YYYY HH:MM:SS, and if a ...
Gortonington's user avatar
  • 30.7k
3 votes
Accepted

Is it possible to convert text field ( textfield1__c) into number field?

You could end up making this way more complicated than it really needs to be. Let's look at the problem that you want to convert a Text field to a Number field. This isn't possible directly without ...
Dan Jones's user avatar
  • 7,227
3 votes

How to remove time from date?

Date.format() method returns the Date as a string using the locale of the context user or if you need it in a specific format regardless User locale use something like Datetime.format('yyyy-MM-dd') ...
edelrabe's user avatar
  • 789
3 votes

Round Decimal and .format() it into a localized output String with more than 3 decimal places

I talked with @ca_peterson, the Salesforce Apex Product Manager, who confirmed that what you're asking for is not possible today. He said there's an idea Have Decimal.format() print more than 3 ...
crmprogdev's user avatar
2 votes

Decimal formatted number in APEX

Just use leftPad, which does exactly what you're looking for. You can specify the character to pad with, or it defaults to the space character (' '). public static String get6DigitRepresentation(...
Adrian Larson's user avatar
  • 151k
2 votes
Accepted

Issue with Datetime().Format() in Batch Apex

You're not using the right format for days. From SimpleDateFormat: D Day in year d Day in month So it sounds like you want to use MM/dd.
Adrian Larson's user avatar
  • 151k
2 votes
Accepted

Help in converting string to datetime in correct format

String strdate = '12/27/2016'; Date newDate = Date.parse(strdate); Datetime dt = Datetime.newInstanceGMT(newDate.year(), newDate.month(),newDate.day(),0,0,0);
chynadoll's user avatar
2 votes
Accepted

How to remove time from date?

Using the format method solve the issue. System.debug('Current date: ' + Date.today().toStartOfMonth().format()); Output: 1-8-2018
Cuban coffee's user avatar
  • 1,596
2 votes
Accepted

Visualforce Excel Export Issue

For anyone looking up this problem in the future, I've used an external JS library called SheetJS. You can put the script tag in your VF page and send the data as a blob to your apex controller. You ...
Atlas Can's user avatar
  • 1,877
2 votes

How to display Month in TEXT format using SQL query in marketing cloud?

If you are looking to display the full name of the month via the SQL query you have written, I would use the below code - utilizing the FORMAT function inside of SQL: FORMAT(yourDateField, 'MMMM') ...
Gortonington's user avatar
  • 30.7k
2 votes
Accepted

Idea Apex Live Templates

When you say you're using IntelliJ, do you mean you're using it with Illuminated Cloud? Illuminated Cloud comes with a collection of live templates: http://www.illuminatedcloud.com/home/completion/...
Aidan's user avatar
  • 13.7k

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