format
Format a Google Sheets cell in plaintext via Apps Script
The other answer, to set the format to ‘plain text’ in javascript, doesn’t work. However, this does: sheet.getRange(1,n).setNumberFormat(‘@STRING@’); So the magic value for formatting text programmatically is ‘@STRING@’!
How to read from input until newline is found using scanf()?
scanf (and cousins) have one slightly strange characteristic: white space in (most placed in) the format string matches an arbitrary amount of white space in the input. As it happens, at least in the default “C” locale, a new-line is classified as white space. This means the trailing ‘\n’ is trying to match not only … Read more
Remove the microseconds from a timedelta object
If it is just for the display, this idea works : avgString = str(avg).split(“.”)[0] The idea is to take only what is before the point. It will return 01:23:45 for 01:23:45.1235
Formatting in percent by Intl.NumberFormat in JavaScript
Because 25.1 is 2510%. Percentages are fractions of 100. If you had 100% it would be 100/100 which is equal to 1. So 25.1% is 25/100 or 0.251 not 25.1 var discount = 0.251; var option = { style: ‘percent’, minimumFractionDigits: 2, maximumFractionDigits: 2 }; var formatter = new Intl.NumberFormat(“en-US”, option); var discountFormat = formatter.format(discount); … Read more
Java Double to String conversion without formatting
Use a fixed NumberFormat (specifically a DecimalFormat): double value = getValue(); String str = new DecimalFormat(“#”).format(value); alternatively simply cast to int (or long if the range of values it too big): String str = String.valueOf((long) value); But then again: why do you have an integer value (i.e. a “whole” number) in a double variable in … Read more
Jackson @JsonFormat set date with one day less
Use this solution, it is more effective and modern than my solution: https://stackoverflow.com/a/45456037/4886918 Thanks @Benjamin Lucidarme. I resolved my problem using: @Temporal(TemporalType.DATE) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = “dd/MM/yyyy”, locale = “pt-BR”, timezone = “Brazil/East”) private Date birthDate; I changed timezone to “Brazil/East” or “America/Sao_Paulo” and working now Thanks
Need to format dates in dynamically built WPF DataGrid
Format the binding by StringFormat: <DataGridTextColumn Header=”Fecha Entrada” Width=”110″ Binding=”{Binding EnterDate, StringFormat={}\{0:dd/MM/yyyy hh:mm\}}” IsReadOnly=”True” /> I think it’s better than writing code behind pieces of code
hook into the builtin python f-string format machinery
Overview You can, but only if you write evil code that probably should never end up in production software. So let’s get started! I’m not going to integrate it into your library, but I will show you how to hook into the behavior of f-strings. This is roughly how it’ll work: Write a function that … Read more
Java: unparseable date exception
What you’re basically doing here is relying on Date#toString() which already has a fixed pattern. To convert a Java Date object into another human readable String pattern, you need SimpleDateFormat#format(). private String modifyDateLayout(String inputDate) throws ParseException{ Date date = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss z”).parse(inputDate); return new SimpleDateFormat(“dd.MM.yyyy HH:mm:ss”).format(date); } By the way, the “unparseable date” exception … Read more