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
  • 23.1k
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 ...
Shane Kenyon's user avatar
  • 1,105
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,873
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.8k
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

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.8k
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.7k
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.4k
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
  • 64.1k
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
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.3k
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
  • 799
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.9k
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,267
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,606
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,887
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.8k
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
  • 14k
2 votes

Is there a way to default the Export CSV file origin of dataloader to UTF-8?

You need to change the encoding before you can see the proper character displayed in Excel. Excel can display the unicode characters correctly if the format is UTF-8 with BOM/Unicode You can use ...
Hengky Djapar's user avatar
2 votes
Accepted

How to pass input of date picker to controller

Apex Page : <apex:page controller="datectrl"> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"/> <script src="...
Rijwandeltax's user avatar

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