You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

1

Thursday, October 22nd 2009, 4:04am

Hour() of meridian-free date/time gives 'wrong' answer

Jabaco Source

1
2
3
Dim d As Date 
   d = CDate("22/2/2009 12:00:00")
   msgbox hour(d)


There is no AM/PM, and Jabaco returns zero. However, VBScript (and I expect VB as well) returns 12.

Kind regards,
Bruce.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Thursday, October 22nd 2009, 9:37am

Yes, this looks like a bug in framework function Conversion.CDate().

I tried the following:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Public Sub Command1_Click()
    Dim sFormat As String   = "dd/mm/yyyy HH:MM:ss"
    Dim sdFormat As java#text#SimpleDateFormat = New SimpleDateFormat(sFormat)
    Dim InputDate As String = "22/02/2009 12:01:00"
    Dim d As Date           = sdFormat.parse(InputDate)
    Dim s1 As String
    Dim s2 As String 
      
    s1 = sdFormat.format(d) & " hour=" & Hour(d) & " day=" & Day(d) & " month=" & Month(d) & " year=" & Year(d)

    d = CDate(InputDate)
    s2 = sdFormat.format(d) & " hour=" & Hour(d) & " day=" & Day(d) & " month=" & Month(d) & " year=" & Year(d)
    
    MsgBox s1 & vbCrLf & s2
End Sub


Java SimpleFormat() does the job. But Month() returns "1" rather than "2" in both cases.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

3

Thursday, October 22nd 2009, 10:56am

Month

Hi,

what the hell... I'm going to go on the warpath with java date.

I thought I've already fixed this?

http://code.google.com/p/jabacoframework…A/DateTime.java


it would really be good to have some more helpers on the Jabaco Framework



OlimilO

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Thursday, October 22nd 2009, 11:09am

I noticed that Conversion.CDate() always assumes the presence of an AM/PM in the input format.
Might be that the default behaves differently from what one would expect.

java.text.SimpleDateFormat() has a format qualifier "a" which stands for the AM/PM marker.
This "a" is present in all formats tried by Conversion.CDate().

VB6 Month() returns months between 1 and 12 (cf. http://msdn.microsoft.com/en-us/library/s70thwaz(VS.80).aspx).
This is different from the java style. Calendar.get(Calendar.MONTH) returns 0 .. 11.

Cheers!

A1880

Rate this thread
WoltLab Burning Board