hour « Date Time « Java Data Type Q&A





1. How do I create a new Joda DateTime truncated to the last hour?    stackoverflow.com

I am pulling timestamps from a file that I want to create a new DateTime for, but I want to create the DateTime at the floor of the hour (or any ...

2. How can i tell if one joda-time DateTime object is within 4 hours of another?    stackoverflow.com

What's the best way to tell if one joda time DateTime object is within 4 hours of another if I don't know which object is earlier than the other? The Joda Time ...

3. Hours corrupted when subtract one day from GregorianCalendar    stackoverflow.com

I use the following code:

Calendar calendar = new GregorianCalendar(0,0,0);
calendar.set(Calendar.YEAR, 1942);
calendar.set(Calendar.MONTH, 3);
calendar.set(Calendar.DAY_OF_MONTH, 4);

Date date1 = calendar.getTime();

calendar.add(Calendar.DAY_OF_MONTH, -1);

Date date2 = calendar.getTime();

System.out.println(date1 + "\n" + date2);
This code output follows:
Sat Apr 04 00:00:00 EEST 1942
Fri ...

4. Find total hours between two Dates    stackoverflow.com

I have two Date objects and I need to get the time difference so I can determine the total hours between them. They happen to be from the same day. The ...

5. JodaTime Calculate total hours worked in a week    stackoverflow.com

Currently I have a function which can take the start time and end time of one day, and calculate the difference between the two, giving me the hours worked in a ...

6. How to trim minutes and hours and seconds from Date object?    stackoverflow.com

I need to make map where Dates are keys. 2 date objects are equals if they have the same value of getTime() method. I'm interested only in year, month and day. How ...

7. Any way to convert a JodaTime Period to a decimal number of hours?    stackoverflow.com

I have a JodaTime Period that I've created from two DateTime instants. Is there a good way to convert that Period into a decimal number of hours? For instance, I have ...

8. Get Date as of 4 hours ago    stackoverflow.com

How can I return a Date object of 4 hours less than the current system time in Java?

9. Using Joda, How do I determine if a given date is between time x and a time 3 hours earlier than x?    stackoverflow.com

What is the simplest way to use Joda time and get something like the following behavior:

public boolean check( DateTime checkTime )
{
    DateTime someTime = new DateTime(); //set to ...





10. Calculate age in Years, Months, Days, Hours, Minutes, and Seconds    stackoverflow.com

I need to take a birthday entered by the user (preferably in dd/mm//yyyy format) and find their age, based on todays date. Could someone explain to me the process I should ...

11. Compare hours and minutes    stackoverflow.com

I am developing an app based on date and time in java. In this app, my user is allowed to record an video only once per hour. so for this I ...

12. JodaTime: Print Period with Days as Hours?    stackoverflow.com

Is there any way to create a PeriodFormatter in JodaTime which is able to print a Period of lets say 2 days, 4 hours and 4 minutes as 52 hours, 4 ...

13. How to determine if a timestamp is within working hours?    stackoverflow.com

Given a any unix timestamp (i.e. 1306396801) which translates to 26.05.2011 08:00:01, how can I determine if this is within a given timeframe (i.e. 08:00:00 and 16:00:00)? This needs to work for ...

14. Is there a class in JDK to represent an hour of the day, but not necessarily a specific hour at a specific date?    stackoverflow.com

Is there a class in JDK or Guava to represent an hour of the day, but not necessarily a specific hour at a specific date? If not, why?

15. Joda Time, parse hours and clockhours at the same time    stackoverflow.com

I want to have a DateTime Parser that can parse a time that is either in "normal" hours or in clockhours. Means that I can have 00:00:00 or 24:00:00 at the same ...

16. Java getHours(), getMinutes() and getSeconds()    stackoverflow.com

As I know getHours(), getMinutes() and getSeconds() are all deprecated in Java and they are replaced with Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND. These will in fact return the hour, minute and second for that ...





17. finding difference b/n two dates in hours    coderanch.com

I don't think it would be appropriate to just give you the solution (which would be quite an amount of code), but there are a few subjects you must know in order to implement the solution: - JDBC: Read the API and Java Tutorial on the subject. You will need it to connect and execute your queries to the Oracle DB ...

18. Date/Time addition losing 1 hour !    coderanch.com

Hi all, Having a problem adding a date to a time and finding I'm losing an hour.. My program received a date and a time as a string, and i'm wanting to create a DateTimeStamp from those two strings, Heres what i'm doing.. // input - sDateStamp & sTimeStamp SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd"); try { DateTimeStamp = new Timestamp(sdf.parse(sDateStamp).getTime()); ...

19. How to compare (Hour) with actual new Date() ?    coderanch.com

I am trying to make a program which will compare the hours with the actual hour of new Date() and I have difficulties with it. Here is what I have so far: File HelloDate3.java import java.util.Date; public class HelloDate3 { public static void main (string [] args) { int hour = Integer.parseInt (args[0]); if (hour >= 06:59:00:00 && hour <=12:59:00:00) { ...

20. Timestamp advanced 4 hours    coderanch.com

22. Hours between two dates    forums.oracle.com

I need to find all the hours between two dates, for instance if the start date is "Wed Jul 01 19:00:00 CDT 2009" and the end date is "Thu Jul 02 02:00:00 CDT 2009", my program is supposed to show Jul 01 20:00:00 Jul 01 21:00:00 Jul 01 22:00:00 Jul 01 23:00:00 Jul 02 01:00:00 Jul 02 02:00:00 I tried to ...

23. current Date one hour before system date    forums.oracle.com

Did Amsterdam's summertime schedule change in the last few years? As a quick check, you could try moving your system date forward to, say, mid-May, and see if things line up again. If your system time is correct and Java is an hour behind it really sounds like your JRE's TZ rules are not correct for your locale. Especially if the ...

24. java.util.Date with 1 hour plus    forums.oracle.com

Thanks, CeciNEstPas, and sorry for the late reply (hope you get this), but the thing is that I'm using Hibernate to store those values in an Oracle database, inside a DATE type column. It seems that internally Hibernate uses the string representation (or the localized date value, I don't know) to store my java.util.Date object into a DATE type column. That's ...