Browsing 7239 questions and answers with Jon Skeet
I would like to get the date format as yyyy-mm-ddT00:00:00 and different TimeZone as an output. Then you need to be using a DateFormat of some description, e.g. SimpleDateFormat. In particular, a DateFormat knows about: The... more 11/18/2014 7:08:31 PM
For the first part of your question, it sounds like you just want static fields or properties, e.g. public class Foo { // A field... public static readonly Foo MyFunkyFooField = new Foo(...); // A property - which could... more 11/18/2014 12:50:47 PM
You need to tell the DateFormat to parse strictly, instead of leniently (the default): SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setLenient(false); sdf.parse("29-09-2014 20:35:27"); // Throws ParseException more 11/18/2014 12:42:32 PM
You want: if (typeof(T) == typeof(MyEnumA)) to compare the types. The is operator is for testing whether a value is of a particular type. Note that having to test for particular types within a generic method suggests that it might not... more 11/18/2014 9:58:55 AM
how should I properly set the class up to be collected by the Java garbage collection. You may not need to do anything. If there are no references to the Duel from elsewhere, then the Duel object itself is eligible for garbage... more 11/16/2014 8:41:55 AM
waka's answer is right about what's wrong - you're declaring new local variables which are entirely independent of the instance variable. However, waka's fix isn't quite right - you can only initialize arrays in that particular way at the... more 11/15/2014 11:20:30 PM
The IDE asks me to rename or delete the first constructor, why? It's because of the way generics work in Java. Due to type erasure, you're effectively declaring two constructors like this: Matrix(List data) That's what the JVM... more 11/15/2014 9:49:53 PM
TreeSet stores its values in order - which means they have to be comparable with each other. You can't compare an Integer with a String, so you get an exception at execution time. If you really want to be able to do this, you could... more 11/15/2014 7:44:29 PM
Just don't do that to start with - it's an abuse of exceptions, IMO. Write the code so it's safe without try/catch. If you don't know whether HR is long enough, use: int cappedEnd = Math.Min(HR.Length, End); for (int i = Start; i <... more 11/15/2014 10:11:10 AM
Yes, it's redundant. If you're going to remove the key anyway, there's no point in changing the entry to have a null value first. It should make no difference to garbage collection anywhere. more 11/15/2014 10:00:08 AM