Browsing 7239 questions and answers with Jon Skeet
Assuming this is a matter of formatting a double value as a String, ensuring there are no trailing insignificant zeroes, I'd advise using a DecimalFormat to control the formatting. For example: import java.text.*; import... more 1/23/2018 8:25:23 AM
You have to use a custom numeric format string - standard numeric format strings always have at least three digits in the exponent. Example with a custom string: using System; public class Test { static void Main() { ... more 1/22/2018 8:28:04 PM
I wouldn't use LocalDate.now() - that depends on your current time zone. A file's age in days of elapsed time can be computed in a time zone neutral manner. Instead, convert the FileTime to an Instant via toInstant, and then you can find... more 1/22/2018 5:20:30 PM
But what if the equation used to calculate the number is the same? can I assume the outcome would be the same too? No, not necessarily. In particular, in some situations the JIT is permitted to use a more accurate intermediate... more 1/22/2018 2:55:31 PM
While encryption can be slow, I wouldn't expect that to be the issue here. I suspect it's the byte-by-byte IO that's causing unnecessary overhead. The simplest way to fix that is with a judicious call to Stream.CopyTo - and while you're at... more 1/19/2018 10:25:02 PM
It's not clear that TFactory has to be a type parameter at all. I'd write this: internal void RunTest<T>(IFactory<T> factory) { T t = factory.Create(); Assert.NotEqual(default(T), t); } Then you can just... more 1/16/2018 6:19:12 PM
Well you can use applyPattern: SimpleDateFormat dateFormat = new SimpleDateFormat("dd"); System.out.println(dateFormat.format(new Date()); // 16 dateFormat.applyPattern("dd-yy"); System.out.println(dateFormat.format(new Date()); //... more 1/16/2018 7:24:03 AM
Both number1 and number2 are negative, as per the documentation: If value is a hexadecimal string, the Parse(String, NumberStyles) method interprets value as a negative number stored by using two's complement representation if its... more 1/15/2018 11:21:26 AM
The immediate problem is this line: OffsetDateTime offsetDate = OffsetDateTime.of(utcZonedDateTime.toLocalDateTime(), offset); That's saying you want the same local date/time, but with the specified offset. That changes which instant in... more 1/15/2018 7:44:38 AM
The boxing conversion uses Integer.valueOf implicitly, so there's no difference between the two. For example, consider this code: public static void main(String[] args) { Integer x = 100; Integer y = Integer.valueOf(100); } The... more 1/14/2018 4:18:42 PM