Skip to content

Tag: datetime

How to sort a list of months with years

I have a list of months with years such as: [12-2014,11-2012,5-2014,8-2012] and I have to sort them with the most recent on top (or the latest date on top) eg. [12-2014,5-2014,11-2012,8-2012] . Does anybody have any idea on how to do this in Java efficiently? EDIT: The class YearMonth is not available, I’m on Java 7 Answer Since you are

Get last week date range for a date in Java

Suppose I have a Date 20 June 2013 How can I get the Date range for the last week, ie in this case 9 June to 15 June. Also if the date was 2nd June 2013 the range should be 26 may to 1 june Answer this is Java Calendar based solution output it’s localized, in my Locale week starts

Removing time from a Date object?

I want to remove time from Date object. But when I’m converting this date (which is in String format) it is appending time also. I don’t want time at all. What I want is simply “21/03/2012”. Answer The quick answer is : No, you are not allowed to do that. Because that is what Date use for. From javadoc of

Unparseable date exception in java

These lines of codes causees this exception what is the possible solution ? Answer Your format is completely wrong. Not only are you using mm (which means minutes) when you probably meant MM, but this: is clearly not in the format You probably want something like EDIT: That works for me in desktop Java: You may want to set the

GPS Time Representation library

I am looking for a Java library that handles conversion to/from GPS Time. GPS Time has an epoch of 6 January 1980, and does not have leap seconds, so it differs from the more standard time representations. Here is the relevant description from wikipedia: While most clocks are synchronized to Coordinated Universal Time (UTC), the atomic clocks on the satellites