Browsing 15980 questions and answers with Jon Skeet

java: timezone getTimeZone("GMT 0700")' timezone useDaylight incorrect

I want to get the time zone information for Los Angeles, now 10/10/2017 is daylight saving time, But I got a different result when I got the time zone in Los Angeles in two...
Jon Skeet
people
quotationmark

I want to get the time zone information for Los Angeles, now 10/10/2017 is daylight saving time So you should ask for the "America/Los_Angeles" zone. That's what it's there for. The "GMT-07:00" zone is a fixed-offset zone - it's only... more 10/10/2017 7:25:07 AM

people

C# ValueTuple properties naming

I'm trying ValueTuple Class in C#, and i have a doubt about properties naming, let's see: If instantiate a ValueTuple declaring the object like this: var tuple1 = (Name: "Name1",...
Jon Skeet
people
quotationmark

There are two different "kinds" of tuples involved here: the .NET ValueTuple<...> types, and C# tuple types. C# tuple types can have element names; ValueTuple<...> types can't. (There's simply nowhere in the type system for... more 10/6/2017 9:03:45 AM

people

ObjectOutputStream does not write objects when taking BufferedOutputStream

I've done my research but it seems I can't find enough documentation on the subject. When trying out some code on Object streams, I came to notice that putting a...
Jon Skeet
people
quotationmark

You're trying to create the ObjectInputStream on the same file that you're writing to - you never even get into the body of your try-with-resources block. Here's what happens: Create the FileOutputStream: file is empty Wrap it in... more 10/5/2017 2:56:56 PM

people

Object from class library not contains methods

Trying to build and use class library in C#. Creating class library: File-New Project-Windows-Classic Desktop-Class Library Code: namespace ClassLibrary2 { public class...
Jon Skeet
people
quotationmark

Add is a static method. You can't call static methods "via" instances in C#. That has nothing to do with it being in a different library. You can call the method as: long result = ClassLibrary2.Class1.Add(10, 20); or if you actually... more 10/5/2017 9:22:33 AM

people

DST changes caused an java.text.ParseException: Unparseable date

Following is the code snippet which is throwing an exception: SimpleDateformat dateFormatter = new SimpleDateFormat("yyyyMMddHHmm"); Date date =...
Jon Skeet
people
quotationmark

You're trying to parse a date/time that didn't occur. We now know that this was in the Sydney time zone. At 2am on October 1st 2017 in Sydney, the clocks went forward to 3am. If you were looking at a clock every minute you'd... more 10/5/2017 9:03:07 AM

people

Explicitly marking derived class as implementing interface of base class

interface IBase { string Name { get; } } class Base : IBase { public Base() => this.Name = "Base"; public string Name { get; } } class Derived : Base//, IBase { ...
Jon Skeet
people
quotationmark

It's explained in sections 13.4.4 to 13.4.6 of the C# 5 specification. The relevant sections are quoted below, but basically if you explicitly state that a class implements an interface, that triggers interface mapping again, so the... more 10/3/2017 9:41:51 AM

people

Why regex Matcher.find not showing a word which meets the criteria

The given regex code is import java.util.regex.*; public class Test { public static void main(String[] args) { String longString = " Derek Banas CA 12345 PA...
Jon Skeet
people
quotationmark

Your pattern includes whitespace after the non-whitespace. That accounts for both of your questions: the space between "Derek" and "Banas" counts as part of the first match, which stops it being part of a match for "Banas" (because you'd... more 10/1/2017 8:55:10 PM

people

Adding elements to different collections in a single lambda expression

I possibly use the wrong terms, feel free to correct. I have a test method which takes a Runnable: void expectRollback(Runnable r) { .. } I can call this method like...
Jon Skeet
people
quotationmark

It's subtle, but I think I've got it. In JLS 15.27.3 we have: A lambda expression is congruent with a function type if all of the following are true: ... If the lambda parameters are assumed to have the same types as the... more 10/1/2017 8:29:15 AM

people

Why does short circuit evaluation work when operator precedence says it shouldn't?

In JavaScript and Java, the equals operator (== or ===) has a higher precedence than the OR operator (||). Yet both languages (JS, Java) support short-circuiting in if...
Jon Skeet
people
quotationmark

Or am I confusing matters? You are. I think it's much simpler to think about precedence as grouping than ordering. It affects the order of evaluation, but only because it changes the grouping. I don't know about Javascript for sure,... more 9/30/2017 7:07:14 PM

people

Using LINQ and lambdas to search Dictionary>Class>List>Struct data

given the following data source: public struct Strc { public decimal A; public decimal B; // more stuff } public class CLASS { public List<Strc> listStrc =...
Jon Skeet
people
quotationmark

You're essentially flattening to a sequence of the struct values - and that flattening is represented with SelectMany. So you want: var res = dict.Values .SelectMany(x => x.listSrc) .Where(ls => ls.A > 3) .Select(ls... more 9/30/2017 9:35:56 AM

people