Browsing 7239 questions and answers with Jon Skeet
It's not at all clear what your current approach is trying to achieve, as it's converting in both decimal and octal. If you just want to check whether the string only contains digits 0-7, it's probably simplest to use a regex: using... more 8/13/2014 8:25:38 PM
You can use my Noda Time library for that. It was created specifically to make things like this simpler. // TODO: Encapsulate this conversion in a separate method LocalDate start = new LocalDate(beginDate / 10000, ... more 8/13/2014 4:02:09 PM
Am I missing something? Yes - you're not using the return value of the method in your first snippet. All you need is to set the return value, just as you're doing in the working case (your second code snippet). Changing the value of... more 8/13/2014 2:41:05 PM
i want to get Date in above format not as string but as 'Date '? You're asking for a Date in a particular format - that's like saying "I want an int in hex format." A Date doesn't have a format - it's just an instant in time. It... more 8/13/2014 1:40:20 PM
This is the problem causing the immediate issue you're seeing: arr = input.split(";", -1); You're assigning a reference to an object of type String[] to a variable of type Object[]. That's fine, but it means you can't store non-string... more 8/13/2014 12:01:19 PM
You're only setting values down to the second, so the millisecond part is left at whatever it was from new Date(). Your description isn't entirely clear, but I suspect you just want: fechaMin.set(Calendar.MILLISECOND, 0); Alternatively,... more 8/12/2014 9:17:30 PM
I would throw some kind of RuntimeException which indicates that you think this really should never happen. That way: If it ever does happen, you find out about it rather than swallowing it and continuing Your expectation that it really... more 8/12/2014 8:21:55 PM
Is there a single query that can get the name field from both of these styles of XML? Yes. List<string> allNames = MyDocument.Descendants("img") // Look for a name attribute first; if there isn't one, find the name //... more 8/12/2014 4:39:14 PM
Sure - you'd use getClass() to find the execution-time type: private final List<A> allKnownValues = ...; List<A> getAllValuesOfTheSameType(A sample) { ArrayList<A> results = new ArrayList<>(); for (A... more 8/12/2014 2:33:48 PM
I know this seems a bit dirty, but I'd do: string xml = "<root>" + text + "</root>"; XDocument doc = XDocument.Parse(xml); XElement returns = doc.Root.Element("returns"); if (returns != null) { string returnsDescription =... more 8/12/2014 2:04:53 PM