Formatter black is not working on my VSCode…but why?

Update 2023-09-15: Now VSCode has a Microsoft oficial Black Formatter extension. It will probably solve your problems. Original answer: I use Black from inside VSCode and it rocks. It frees mental cycles that you would spend deciding how to format your code. It’s best to use it from your favorite editor. Just run from the … Read more

Double parameter with 2 digits after dot in strings.xml?

Just adding to @David Airam’s answer here; the “incorrect” solution he gives is actually correct, but with a bit of tweaking. The XML file should contain: <string name=”resource1″>Hello string: %1$s, and hello float: %2$.2f.</string> Now in the Java code: String svalue = “test”; float sfloat= 3.1415926; String sresult = getString(R.string.resource1, svalue, sfloat); The exception that … Read more

How can I correctly format currency using jquery?

Another option (If you are using ASP.Net razor view) is, On your view you can do <div>@String.Format(“{0:C}”, Model.total)</div> This would format it correctly. note (item.total is double/decimal) if in jQuery you can also use Regex $(“.totalSum”).text(‘$’ + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, “$1,”).toString());

datetime: Round/trim number of digits in microseconds

The simplest way would be to use slicing to just chop off the last three digits of the microseconds: def format_time(): t = datetime.datetime.now() s = t.strftime(‘%Y-%m-%d %H:%M:%S.%f’) return s[:-3] I strongly recommend just chopping. I once wrote some logging code that rounded the timestamps rather than chopping, and I found it actually kind of … Read more