Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd80c10

Browse files
committed
There are errors in the PGmoney class in the conversion routines over
the handling of negative numbers and commas. The attached path attemptsto fix these.However the getValue method does not yet insert commas into thegenerated string.Also in getValue there is an incorrect assumption that the currencysymbol is '$', it should of course be '£'!. I have no idea on how to goabout fixing this one.Alvin
1 parent817a3e6 commitfd80c10

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

‎src/interfaces/jdbc/postgresql/util/PGmoney.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,22 @@ public PGmoney()
4848
publicvoidsetValue(Strings)throwsSQLException
4949
{
5050
try {
51-
val =Double.valueOf(s.substring(1)).doubleValue();
51+
Strings1;
52+
booleannegative;
53+
54+
negative = (s.charAt(0) =='-') ;
55+
56+
s1 =s.substring(negative ?2 :1);
57+
58+
intpos =s1.indexOf(',');
59+
while (pos != -1) {
60+
s1 =s1.substring(0,pos) +s1.substring(pos +1);
61+
pos =s1.indexOf(',');
62+
}
63+
64+
val =Double.valueOf(s1).doubleValue();
65+
val =negative ? -val :val;
66+
5267
}catch(NumberFormatExceptione) {
5368
thrownewSQLException("conversion of money failed - "+e.toString());
5469
}
@@ -80,6 +95,11 @@ public Object clone()
8095
*/
8196
publicStringgetValue()
8297
{
83-
return"$"+val;
98+
if (val <0) {
99+
return"-$" + (-val);
100+
}
101+
else {
102+
return"$"+val;
103+
}
84104
}
85105
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp