craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > General QuickTable Support/Help Post New Topic   Post A Reply
Time values printer friendly version
next oldest post
Author Messages
beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Wednesday, August 22, 2012 @ 09:43:34  

For some time I've wanted an easy-to-use Java grid control that I can bind to various data sources, and QuickTable could be just what I'm looking for. It takes minimal set-up and has great flexibility.

However, when I downloaded the jar and tried to compile a program using it, I got an "Incompatible class version" error due to the fact that my organization uses Java 1.4. This minor problem went away when I got the source code and compiled it (with no problems) under Java 1.4, but you may want to consider offering a version compiled with "-target 1.4".

The reason for this post is that I noticed that the Calendar dialog can't properly set times in the afternoon. I entered hour=0, minute=4, AM/PM=PM but instead of the "12:04" that my DateFormat should show, it showed "22:04". A couple of little changes to DBTableCalendarDialog.java will fix this:

*** orig/quick/dbtable/DBTableCalendarDialog.java 2012-08-22 09:34:24.778803900 -0400
--- quick/dbtable/DBTableCalendarDialog.java 2012-08-22 09:20:26.028804200 -0400
***************
*** 175,181 ****
public Date getDateLocal() {
Calendar timeKeeper = Calendar.getInstance();
timeKeeper.set(getYear(), getMonth(), getDay(), getHour(), getMinute());
! timeKeeper.set(Calendar.AM_PM, getAM());
return timeKeeper.getTime();
}

--- 175,181 ----
public Date getDateLocal() {
Calendar timeKeeper = Calendar.getInstance();
timeKeeper.set(getYear(), getMonth(), getDay(), getHour(), getMinute());
! //timeKeeper.set(Calendar.AM_PM, getAM()); GRB MOD 2012-08-21 (also see getHour below)
return timeKeeper.getTime();
}

***************
*** 279,286 ****
{
int h = Integer.parseInt(hour.getText());

! if( h > 12 )
! return 12;
else
return h;
}
--- 279,291 ----
{
int h = Integer.parseInt(hour.getText());

! // START GRB MOD 2012-08-21 (also see getDateLocal above)
! if(am.getSelectedIndex() == 1) {
! h += 12;
! }
! if( h > 23 )
! return 23;
! // END GRB MOD 2012-08-21
else
return h;
}

I've never used CVS in pserver mode before, but if I can get it working I'll upload this patch.

beardsley
Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, August 23, 2012 @ 19:09:53  

Sorry, I got confused about CVS when I was following links trying to download the source. I see now that java.net doesn't use CVS -- is yours a Subversion repository?
Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Friday, August 24, 2012 @ 12:50:56  

Hi, thanks for your patch. we use Mercurial for version control.

Below link gives more details about how to create a patch.diff using mercurial. Could you create a patch using this approach?

http://code.google.com/p/rawtherapee/wiki/MercurialHowto

If you use Eclipse, there is a Mercurial plugin available.

Thanks.

beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Saturday, August 25, 2012 @ 00:28:28  

Ah, that clears up a lot. I guess I could have done a little research first and found out what Mercurial is, but now I'll know next time.

It seems easy enough to use. My patch:

# HG changeset patch
# User Gary Bradshaw <gbradshaw@davisvision.com>
# Date 1345871939 -3600
# Node ID 45f6cad318281ce0b90985b91938dd8318dfc665
# Parent df4bd0488bc9897952eda520972ec963d233ab4c
PM time fix

diff -r df4bd0488bc9 -r 45f6cad31828 quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java
--- a/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Sun Aug 07 23:08:19 2011 -0400
+++ b/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Sat Aug 25 06:18:59 2012 +0100
@@ -175,7 +175,7 @@
public Date getDateLocal() {
Calendar timeKeeper = Calendar.getInstance();
timeKeeper.set(getYear(), getMonth(), getDay(), getHour(), getMinute());
- timeKeeper.set(Calendar.AM_PM, getAM());
+ //timeKeeper.set(Calendar.AM_PM, getAM());
return timeKeeper.getTime();
}

@@ -279,8 +279,11 @@
{
int h = Integer.parseInt(hour.getText());

- if( h > 12 )
- return 12;
+ if(getAM() == 1) {
+ h += 12;
+ }
+ if( h > 23 )
+ return 23;
else
return h;
}

beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Saturday, August 25, 2012 @ 07:22:39  

I see what Calendar is doing to us here. The Java authors didn't accommodate the possibility that someone might set the hour and then set the AM_PM indicator without doing a "get" in between. In this case Calendar ignores the hour given and substitutes the current local time's hour, adding 12 to it if it is less than 12. (That means it's probably right for two hours every day.)

For the curious, here's my test code:

Code:
import java.util.*;

import java.text.*;
public class TestCal {

static public void main(String[] args) {
int hour = 0;
if (args.length > 0) {
hour = Integer.parseInt(args[0]);
}
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");
Calendar cal = Calendar.getInstance();
cal.set(2012, 1, 1, hour, 22, 22);
// Uncommenting the following statement corrects the issue
//System.out.println(fmt.format(cal.getTime()))
cal.set(Calendar.AM_PM, Calendar.PM);
System.out.println(fmt.format(cal.getTime()));
}
}

beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Monday, August 27, 2012 @ 08:22:19  

And before someone else points it out: I made an error in my second patch above. It makes absolutely no difference, but it's an error nonetheless, and I hate when that happens.

It's OK to say "am.getSelectedIndex() == 1", and it's OK to say "getAM() == Calendar_PM", but the fact that "getAM() == 1" works is purely coincidental. (I misread the definition of getAM the first time.)

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Wednesday, August 29, 2012 @ 06:09:29  

Hi, thanks for your patch. Is your patch up to date based on your last comment? Is it good for commit?
beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Wednesday, August 29, 2012 @ 07:53:32  

It works just fine, but it's "wrong". I'll add another changeset and send the correct patch tonight when I get home (Mercurial is blocked by the firewall here at work).
beardsley
Private

Gender: Male
Location: Mohawk Valley NY
Registered: Aug 2012
Status: Offline
Posts: 6

Click here to see the profile for beardsley Send email to beardsley Send private message to beardsley Find more posts by beardsley Edit or delete this message Reply w/Quote
Posted Wednesday, August 29, 2012 @ 21:04:36  

OK, I'm happy with this patch.

# HG changeset patch
# User Gary Bradshaw <gbradshaw@davisvision.com>
# Date 1345871939 -3600
# Node ID 45f6cad318281ce0b90985b91938dd8318dfc665
# Parent df4bd0488bc9897952eda520972ec963d233ab4c
PM time fix

diff -r df4bd0488bc9 -r 45f6cad31828 quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java
--- a/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Sun Aug 07 23:08:19 2011 -0400
+++ b/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Sat Aug 25 06:18:59 2012 +0100
@@ -175,7 +175,7 @@
public Date getDateLocal() {
Calendar timeKeeper = Calendar.getInstance();
timeKeeper.set(getYear(), getMonth(), getDay(), getHour(), getMinute());
- timeKeeper.set(Calendar.AM_PM, getAM());
+ //timeKeeper.set(Calendar.AM_PM, getAM());
return timeKeeper.getTime();
}

@@ -279,8 +279,11 @@
{
int h = Integer.parseInt(hour.getText());

- if( h > 12 )
- return 12;
+ if(getAM() == 1) {
+ h += 12;
+ }
+ if( h > 23 )
+ return 23;
else
return h;
}
# HG changeset patch
# User Gary Bradshaw <gbradshaw@davisvision.com>
# Date 1346291730 -3600
# Node ID 51e502f3de7065b114c7a125f05015e2e5cc84c4
# Parent 45f6cad318281ce0b90985b91938dd8318dfc665
The right way to use getAM

diff -r 45f6cad31828 -r 51e502f3de70 quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java
--- a/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Sat Aug 25 06:18:59 2012 +0100
+++ b/quicktable-main/src/main/java/quick/dbtable/DBTableCalendarDialog.java Thu Aug 30 02:55:30 2012 +0100
@@ -279,7 +279,7 @@
{
int h = Integer.parseInt(hour.getText());

- if(getAM() == 1) {
+ if(getAM() == Calendar.PM) {
h += 12;
}
if( h > 23 )

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios