Browsing 7239 questions and answers with Jon Skeet

java JodaTime remove seconds

I am using JodaTime to create ISO 8601 String. DateTime jodatime = new DateTime(2016, 04, 05, 23, 59, 59, 999, DateTimeZone.UTC); String converted =...
Jon Skeet
people
quotationmark

The normal way of formatting a Joda Time value is using a formatter. In this case, the format you want is already available, except for the Z: DateTimeFormatter formatter = ISODateTimeFormat.dateHourMinute(); String text =... more 4/5/2016 8:13:01 PM

people

What is the difference between Convert.ToInt32 and (int) Parsing

I can't understand the difference between Convert.ToInt32 and Parsing (int) command when i convert a double number to a int number.My example code is here and i have two different...
Jon Skeet
people
quotationmark

From the documentation from Convert.ToInt32(double): Return Value Type: System.Int32 value, rounded to the nearest 32-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is... more 4/5/2016 7:57:07 PM

people

String literal not working

String name = ...; //some method System.out.println(name); //output \u5f20\u4f73\u73ae String name2 = "\u5f20\u4f73\u73ae"; //looks the same as the output...
Jon Skeet
people
quotationmark

If System.out.println(name) prints out a backslash followed by a u etc, then that's what's in the string... whereas in String name2 = "\u5f20\u4f73\u73ae"; ... you've got Unicode escape sequences... that's just 3 characters. If you want... more 4/5/2016 6:45:47 PM

people

where is the command line config saved in .csproj?

I'm working on a C# project on Visual Sutio 2015 community. I changed the Properties debug-command-line, Is stored in local machine, bug there are no changes in .csproj file, so I...
Jon Skeet
people
quotationmark

It's in the Foo.csproj.user file, as that's basically a user-specific setting. (Different users will often want different command line options.) I wouldn't suggest pushing that to git. more 4/5/2016 4:29:48 PM

people

Using ThenBy in DocumentDb shows error

Does DocumentDb supports multipe OrderBy and ThenBy ? I have been using this query with both approaches including two OrderBy and one orderBy and one ThenBy but every time it says...
Jon Skeet
people
quotationmark

Is there any way to use order by with multiple fields? Not at the moment, no. It's a documented limitation, although it sounds like work is being done on it: You cannot perform the following: [...] Order By multiple... more 4/4/2016 6:05:36 AM

people

Null value in the result of a left outer join linq causes error

I have linq query, that left outer join two tables. I found if a value of a field returns null,, then I will get an error message: "The cast to value type 'System.Int32' failed...
Jon Skeet
people
quotationmark

I'm slightly surprised at the kind of error you're getting, but there are two places you need to take account of the possibility of the result being null: Within the query, where r can be null. (If you don't want to match when there are... more 4/4/2016 5:54:32 AM

people

double that I converted into String adding int type

This is very weird. The following is the code: public static void main(String [] args) { double db = 56.00; String st = String.valueOf(db); System.out.print(st+3); ...
Jon Skeet
people
quotationmark

You're performing string concatenation. The value of st is "56.0", and then you're performing a concatenation of that and the int 3, giving a result of "56.03". The string concatenation + operator is described in JLS 15.18.1. It starts... more 4/3/2016 8:22:24 PM

people

Json single object string into List<string>

I am having a hard time getting a simple json object into a List var returnedJson = ["applicant", "recruiter", "team"]; NOT WORKING List<string> list =...
Jon Skeet
people
quotationmark

You need to specify List<string> as the type argument to DeserializeObject: var list = JsonConvert.DeserializeObject<List<string>>(returnedJson); more 4/2/2016 3:02:25 PM

people

Visual Studio 15 vs 2015 + Update 2

I can choose from two possibilities of new Visual Studio installation Visual Studio 15 Preview Visual Studio 2015 + Update 2 But I'm a little bit confused what do these...
Jon Skeet
people
quotationmark

Visual Studio 15 is the version after Visual Studio 2015. The "15" is effectively the mostly-internal version number, and the "2015" is the branding version. Yes, it's very confusing. Other internal/branding mappings: Visual Studio 97 /... more 4/2/2016 2:57:48 PM

people

DateTime.ToString() not converting time

Looks like time is automatically getting changed during conversion. My input is 17:15:25. However, it gets converted to 13:15:25 What could be the reason? string testDate =...
Jon Skeet
people
quotationmark

The Z in your input indicates a UTC time, but the default behaviour of Convert.ToDateTime is to convert the result to your local time. If you look at the result of Convert.ToDateTime("2016-03-30T17:15:25.879Z").Kind you'll see it's... more 4/1/2016 1:52:17 PM

people