Browsing 7239 questions and answers with Jon Skeet
The simplest option would probably be to use String.replaceAll: text = text.replaceAll("[0.]*$", ""); The $ makes sure it's only trimming the end of the string. Note that if you start with "0" you'll end up with an empty string - think... more 8/8/2014 11:29:52 AM
An import statement just makes the type available by its short name without specifying the package. That's all it does. It's not like the class can't be used without an import. Usually it's clearer to use an import instead, but sometimes... more 8/8/2014 11:17:56 AM
Your format doesn't match the one they've required. For example: Theirs: 2011-08-21T18:02:52.249Z Yours: 2011-08-21 18:02:52.249 You're missing the T and the Z. So try changing your format to: SimpleDateFormat formatter = new... more 8/8/2014 11:02:38 AM
I suspect you want: public static T GetCacheItem<T>(String key, Func<string, T> cachePopulate) { // TODO: Try to get it from the cache // But if not... T result = cachePopulate(key); // TODO: Cache it ... more 8/8/2014 10:19:19 AM
Type.FullName doesn't include the assembly - so unless the type is in either the calling assembly or mscorlib, it won't be found. Basically, if you're trying to load a type from an arbitrary assembly there are two simple options: Use... more 8/8/2014 10:11:25 AM
It's probably simplest to just fetch the data from EF, and then perform the arithmetic locally: var today = DateTime.Today; var rawData = from r in db.Repairs join c in db.Car on r.Car equals c.ID_Car join m in... more 8/8/2014 9:18:54 AM
I would separate parsing from everything else. Parse the value as you're already doing, which gives you a date in the wrong year. From that, take the time of day and the day of week - those are the important things. You can throw... more 8/8/2014 8:50:43 AM
As I understand it, contains() should call equals() of the contained Objects Not for TreeSet, no. It calls compare: A NavigableSet implementation based on a TreeMap. The elements are ordered using their natural ordering, or by a... more 8/8/2014 7:52:32 AM
Well you can avoid nested loops by performing a dictionary lookup instead: public void UpdateList(IDictionary<int, int> sortOrder) { var current = GetList(); foreach (var item in current) { int value; if... more 8/8/2014 7:04:02 AM
(Java syntax, but I'm sure you can change it to Scala easily enough.) In decreasing order of preference... With Java 8: // TODO: Which time zone are you interested in? YearMonth yearMonth = YearMonth.now(); DateTimeFormatter formatter =... more 8/8/2014 6:43:47 AM