 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- Swing GUI problem - after a compile, components shift back to original size/position.This is frustrating! I am designing a simple panel using the XYLayout. I
quite often get into a situtation (not sure why/how) where I am aligning
some components by multi-selecting them and choosing "Align Left" from the
right-mouse context menu for example. The UI aligns them perfectly and
things look great. BUT when I compile (Ctrl-Shift-F9) the components that I
just aligned go right back to their old position. I see this sort of stuff
ALL THE TIME using this GUI. I bring a component to the front of another
object....re-compile, and poof! the component goes right back to the
previous state. I have wasted literally hours and hours fighting JBuilder
trying to get out of this situation. I delete the components, re add
them...I try to go to the source and move contructors around and recompile.
Sometimes it helps, but most times it does not.
What is up?? I am using JBuilder 10. I would think version "10" would be a
little more stable than this. I recently started using JBuilder again since
moving from another IDE. I saw this same issue when I was using Jbuilder 7.
Man is this frustrating.
Any help please?
Thanks in advanced.
- 4
- draw line position - networkingThe code bellow will enable users to scrible anything on a canvas. Now
what I intend to do is to create a vector object for every position
(pre_x,pre_y,x, y) of the lines drawn on the canvas and send it using
a socket connection to a remote server.
public void mouseDragged(MouseEvent e)
{
if(isButtonPressed==true)
{
pre_x=e.getX()+scrollbarH_value;
pre_y=e.getY()+scrollbarV_value;
isButtonPressed=false;
}
x=e.getX()+scrollbarH_value;
y=e.getY()+scrollbarV_value;
offscreenImageG.drawLine( pre_x, pre_y, x, y);
pre_x=x;
pre_y=y;
repaint();
e.consume();
message.setText(pre_x + ":" + pre_y + ":" + x + ":" + y);
}
Is my apporach considered to be feasible?. Any other ways?
Regards.
- 6
- Java Mail: Is There A Simple Way to Get ALL Message HeadersI'm working with javax.mail.*. I have no problem with reading in messages.
I'm not using multi-part messages or anything, I just use this setup:
Session oSession = Session.getDefaultInstance(props, null);
try {
oStore = oSession.getStore("pop3");
oStore.connect(sInServer, sInName, sInPass);
oFolder = oStore.getFolder("INBOX");
oFolder.open(Folder.READ_WRITE);
oMessage = oFolder.getMessages();
if (oMessage.length == 0) {return;}}
} catch (Exception e)
{System.out.println("Problem with opening and getting messages: " + e);}
for (int i=0, n = oMessage.length; i < n; i++) {
try {
System.out.println(i + ": " + oMessage[i].getFrom()[0] + "\t"
+oMessage[i].getSubject());
} catch (Exception e)
{System.out.println("Problem printing message info: " + e);}
try {sContent = (String) oMessage[i].getContent();} catch (Exception e)
{System.out.println("Problem getting message content: " + e);}
//From here, do stuff with the message -- like saving the content
}
The code is still new, so I'll be using actual error handlers.
Here's the problem: There are times when I want to save a copy of the ENTIRE
message, including the headers, so I can use the headers later (possible
spam filtering and other stuff).
I've found the getHeader() and similar functions in Java Mail that return
headers as objects. Isn't there some SIMPLE and quick way to get a string
that contains all the headers? Like a "Header" version of getContent()?
I basically just want to dump the header and content to the drive. I
thought I read somewhere that there was a call to use to get the full
header and content together, but I haven't been able to re-locate it or
verify it's what I read.
Thanks for any help!
Hal
- 6
- Modify java AST before compilingHi !
I'm trying to modify an Abstract Syntax Tree (a
com.sun.tools.javac.tree.JCTree).
I can get the AST with something like that:
// new compiler, fileManager, compilationUnits1.....
CompilationTask ct = compiler.getTask(null, fileManager, null, null,
null, compilationUnits1);
JavacTask jt = (JavacTask)ct;
try {
Iterable trees = jt.parse();
//... do something else here....
} catch (IOException e) {
e.printStackTrace();
}
Then, I obviously can walk throw the tree....
I now want to modify this AST. Is there any simple way to achieve this
?
For example, if a leaf is a JCBlock, I would like to do something like
that (Just to test):
((JCBlock)t).stats.append(((JCBlock)t).getStatements().last());
but it seems that everything is read-only in those JCTrees.
Then, I would like to generate the .class with the modified tree... any
idea ?
Thank you !
Best regards,
Yohann Coppel.
- 8
- IO ExceptionHi,
I have a Java application which takes in either the server name or IP
address, domain name, user name and password, and copies the files
from the specified server directory to the local C drive.
It works perfectly fine when I run this on my local m/c and I can use
either the server name or the server IP address.
But when I move the jar file to a different workstation and execute it
I get an IO exception - 'Source file does not exist' when I specify
the server using its IP address. It still works on a different
workstation when I pass the server name.
Any clue as to why should it happen?
Thanks,
Beena
- 9
- Java Programming JobsThis is a cool site that aggregates fresh job listings from multiple
sites (such as hotjobs, monster, careerbuilder, dice, craigslist etc
just to name a few) to find all jobs with a single search:
http://www.jobrobots.com.
Some of the cool features include:
**Fresh - JobRobots limits its data to only jobs posted within the last
2 to 3 weeks to ensure the content and listings are current.
**Easy - The site collects jobs from many job portals, and provides one
place for job search. No more old-fashion way of searching jobs one by
one from different sites!
**Efficiency - The search understands geographical surrounding and can
automatically search cities around a specified location. For example,
if you search for "manager" jobs in San Jose, CA, the search will
automatically search 21 surrounding cities to find all available jobs.
**Daily notifications - You can subscribe to job notification to get
daily updates on the latest jobs
**Communication - The site also builds an easy way to ask your friends
for information regarding a job or to tell your friends about a job
they may be looking for.
Give it a try - I think you will like it.
==> http://www.jobrobots.com
- 9
- How to load class files in Tomcat4?Hi,
All those .class have worked well in Tomcat 3. They were under
webpages (html's and jsp's)/WEB-INF/classes.
Now in Tomcat 4, they no longer work, even after re-compiling. Jsp's
can longer connect to the beans (classes). What's my problem? Yes I
noticed that all the simple jsp's did produced a .java and .class in
the jakarta-tomcat4.0/work, but all the jsp's using beans only
produced a .java not .class. Obviously, beans are "lost".
I also noticed there is a web.xml in each WEB-INF. Do I need to do
anything there for deployment?
Thanks a lot,
Wayne
- 9
- Java Print Service and WindowsIs there a way to print simple text using the Java Print Service under
Windows? The target printer is a high speed dot matrix printer that
does not support graphics. This works without any problems under Linux,
but no matter what printer driver is installed on a Win2K machine, JPS
fails to locate a print service for DocFlavor.READER.TEXT_PLAIN (or any
DocFlavor.*.TEXT_*).
Any ideas?
- 9
- Another exception handling question
public void myMethod (String name){
if(!condition1){
throw new IllegalArgumentException("A message ");
}
if(!condition2){
throw new IllegalArgumentException("Another mesage");
}
}
When I call myMethod I want to distinguish between the different
reasons for the same exception. Is it better to make my own
exception ? What is my good practice?
cheers,
//mike
- 10
- launch applicationHello, does someone knows if i can launch a vrmlviewer (ex vrmlView) from a
java application?
Thanks
S
- 11
- DesktopManager implementation questionBefore I go reinventing the wheel, does anyone know of a pointer to a
DesktopManager implementation that handles resizing properly when its
internal frames are minimized?
Specifically, I'm looking for some set of behavior equal to or greater
than the following:
When an internal frame is iconified AND the look and feel has
located that iconified frame at the bottom of the desktop AND the
desktop is resized, THEN the iconified frame should reoccupy the
appropriate position in the newly-sized desktop.
Right now what happens is that the iconified frame simply stays where it
is. This is in keeping with a container that really doesn't have a
layout manager, but it's not what a user would expect.
Thanks in advance for any pointers; I have done my homework via Google,
this newsgroup, etc. but haven't found anything. There are plenty of
examples of putting a JDesktopPane into a JScrollPane, but for various
reasons I'd really REALLY like to avoid this if possible.
Thanks,
Laird
- 12
- Printing using 1.1 API - big gray square in upper leftI'm trying to print using Java, for the first time. I decided to use
the 1.1 API because it's simple and adequate for the simple line drawing
I'm trying to display (a maze). I'm actually drawing on the Graphics
object received from the PrintJob directly, scaling my diagram to the
reported dimensions. The drawing is done with a series of
Graphics.setColor() and Graphics.drawLine() calls -- nothing else. The
only colors I set to are white and black, and the same routine that
draws to the page also is used to draw to a 400x400 JFrame's ContentPane
successfully.
It mostly works, the upper left corner of each 8.5" x 11" page is
obscured by a light gray square, measuring roughly 5" x 5". The square
only shows up when I draw to the printer -- not to the JFrame/ContentPane.
What on earth could cause this? Any ideas?
Thanks,
Bruce Feist
- 14
- Premature optimization (Was: Java Future)
Tom Forsmo wrote:
> amanda wrote:
> > Daniel Pitts wrote:
> >> they avoided using it unless there was a time-critical project involved.
> > Can you Elaborate on the above statement?
I did, it was the quote of Knuth. Optimizing early wastes time,
energy, and money. Not just early, but later during maintanence.
>
> only optimise a piece of code with assembly if that part of the code is
> time-critical.
The truth is, generally you can optimize your algorithm effectivly
without resorting to worring about a cycle here or a byte there.
Sometimes, if you're on the cutting edge of technology, you need to
trim as much as possible. However, in most circumstances, having a
profiler to tell you exactly what part of your code is taking the most
amount of time, and then fixing that, is the best way to go. Often
times you'd be surprised by what is actually slow versus what you would
expect to be slow.
- 14
- Setting the SAX implementationHello everybody
I'am using the org.xml.sax.helpers.ParserAdapter to read a
XML file. When I launch my program, the jvm said that I haven't
set the property org.xml.sax.xxx . I just use the Crimson implementation
from de Sun jdk, but how to invocate it ?
Alex...
[PS] Sorry fro the frenglish...
- 14
- Confusion between SCJP 1.5 and SCJP 1.6Hi,
I want to give a SCJP certification.
But now SCJP 1.6 is latest and I have prepared for SCJP 1.5.
Can anyone tell me which will be best?
If possible provide some useful links.
Thanking in Advance
Sanjeev
|
| Author |
Message |
nag

|
Posted: 2006-1-10 19:31:00 |
Top |
java-programmer, Handling of DST in java
Hi,
Does java handle DST automatically ?
I'm using java Gregorian calendar to get the time/date. Does this
automatically give the local time/date iirrespective of DST or special
handling should be done ?
|
| |
|
| |
 |
Thomas Weidenfeller

|
Posted: 2006-1-10 21:44:00 |
Top |
java-programmer >> Handling of DST in java
nag wrote:
> Does java handle DST automatically ?
> I'm using java Gregorian calendar to get the time/date. Does this
> automatically give the local time/date iirrespective of DST or special
> handling should be done ?
What do you really want to do? If you need to represent a point in time
internally in your application, then a calendar is a bad choice. Use a
Date() object, or the time (as a long, in milliseconds). Java keeps its
date/time in milliseconds since Jan .1st, 1970 00:00 GMT. Only when you
you do some I/O you should consider if you want to have GMT/UTC
date/time, or local time (with DST)
E.g. if you just need to print out some time, [Simple]DateFormat is
often a much better choice than a calendar. It takes the local time-zone
into account, and you an specify another zone. Time-zone information
contains DST information.
A calendar is useful for presenting(!) some point in time in, guess
what, calender format, and doing some calculations based on this
representation, but not more. The representations produced by
GregorianCalender are somewhat imprecise. E.g. GregorianCalendar doesn't
know about leap seconds.
GregorianCalender does take time-zone information (and thus DST, if
defined for a time-zone) into account. But if I remember correctly, does
so inconsistently. If I remember correctly, then it sometimes assumes a
change from/to DST happens at midnight local time, which is wrong for
several time-zones. GregorianCalender also has a problem with the times
which appear twice when the clock is turned back at the end of DST. You
can't specify if you want to have the A (DST) or B (standard) time when
you e.g. set the HOUR value, or when you move into that period with and
add().
Doing timekeeping with a calender is usually a bad idea in Java.
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-1-11 2:27:00 |
Top |
java-programmer >> Handling of DST in java
On Tue, 10 Jan 2006 17:00:44 +0530, "nag" <email***@***.com> wrote,
quoted or indirectly quoted someone who said :
>Does java handle DST automatically ?
>I'm using java Gregorian calendar to get the time/date. Does this
>automatically give the local time/date iirrespective of DST or special
>handling should be done ?
Yes. However, because the tables are so voluminous, and because
people think it fun to change the rules, as if they were ordering the
sun to change it rising time, Sun's tables will always be a little
off.
I think it is a nutty idea. It creates two goofy anomalies each year
-- a missing hour and an hour lived twice. Leave the time alone and
just declare different summer and winter business hours.
Non-compliance would help spread rush hour.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
ram

|
Posted: 2006-1-11 2:44:00 |
Top |
java-programmer >> Handling of DST in java
Roedy Green <email***@***.com> writes:
>I think it is a nutty idea. It creates two goofy anomalies each year
>-- a missing hour and an hour lived twice. Leave the time alone and
>just declare different summer and winter business hours.
I agree. It just seems to be an attempt to show to power of
the government, "look, we can change the run of the time!" or
"Look, we can make completely idiotic rules, still you have to
live by them."
In 2005, US-president Bush signed a paper to extend DST by
four weeks in the USA (starting in 2007), and to make life
even more complicated by adding another rule modification ...
There is an "international movement" against it, the German
website is
http://www.initiative-sonnenzeit.de/
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2006-1-11 2:58:00 |
Top |
java-programmer >> Handling of DST in java
Roedy Green wrote On 01/10/06 13:27,:
> On Tue, 10 Jan 2006 17:00:44 +0530, "nag" <email***@***.com> wrote,
> quoted or indirectly quoted someone who said :
>
>
>>Does java handle DST automatically ?
>>I'm using java Gregorian calendar to get the time/date. Does this
>>automatically give the local time/date iirrespective of DST or special
>>handling should be done ?
>
>
> Yes. However, because the tables are so voluminous, and because
> people think it fun to change the rules, as if they were ordering the
> sun to change it rising time, Sun's tables will always be a little
> off.
>
> I think it is a nutty idea. It creates two goofy anomalies each year
> -- a missing hour and an hour lived twice. Leave the time alone and
> just declare different summer and winter business hours.
> Non-compliance would help spread rush hour.
Why stop there? Get rid of this silly business of
time zones and just run the entire world on UTC. (That
way I'll have a good excuse for lying in bed until noon
and not returning there until tomorrow morning.)
While we're at it, let's reform the calendar: Who
needs this arbitrary assortment of irregularly-sized
months, anyhow? "Thirty days hath September / The Ides
come on the fifteenth day ..." Bosh! And look at all
the confusion it's caused, what with the Merkins and
Yoorops unable to tell whether 6/6 is June 6 or 6 June.
A simple day-of-year count of 1..365 (0..365 in Leap
Year) would do just fine. Knowing that today is the
10th and Christmas is the 359th would make it much
easier to count those shopping days ...
Come to think of it, who really needs a count of
years any more? We'll just get all of civil society to
switch to counting milliseconds since, since, well I
guess we'll just call it Millisecond Zero. "You are
charged with serving alcohol to a person under the age
of 568036800000, for which you could be sent to prison
for as long as 126230400000. How do you plead?" See
how much simpler things are when you don't need to
specify which of a multitude of confusing units is
meant?
Roedy, I think you've got something -- and if you'll
let me smoke some, too, I won't rat to the narcs.
--
email***@***.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-1-11 4:13:00 |
Top |
java-programmer >> Handling of DST in java
On 10 Jan 2006 18:44:28 GMT, email***@***.com (Stefan Ram)
wrote, quoted or indirectly quoted someone who said :
> I agree. It just seems to be an attempt to show to power of
> the government, "look, we can change the run of the time!" or
> "Look, we can make completely idiotic rules, still you have to
> live by them."
Local time is a concept on its way out. With netmeetings across the
globe, you have to arrange your meeting in some common global base
time, be it UTC , EST or head office time.
Similarly for satellite broadcasts across time zones.
As travel speeds up, we may find even meetings between in and out of
towners arranged in some common base -- NOT local time.
When a politician meddles with the rules for time, it creates a
headache for anyone who has a payroll system, or anything that runs 24
hours.
I first became aware of the problem back in the 1970s. To my surprise,
"war time" as it was originally called was quite chaotically employed,
using an offset up to 5 hours, with every community separately making
up their own rules about when to kick in and out each year.
Railroads refused to play and published their schedules in standard
time. I suppose with computers they have now relented.
I like the idea of keeping correlation between time and position of
the Sun in the sky. Pretending the sun in irrelevant to man's
activity is just arrogance. It enforces the idea that man is not an
animal with the same environmental limitations that face all animals.
Java wisely stores all dates in UTC and considers timezone merely a
display quirk, not something inherent in the measurement.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-1-11 4:17:00 |
Top |
java-programmer >> Handling of DST in java
On Tue, 10 Jan 2006 13:57:47 -0500, Eric Sosman <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
> Come to think of it, who really needs a count of
>years any more?
At some point that will have to happen. Years are a very earth-centric
measure, hardly suitable for a civilisation spanning many worlds.
If someone discovers time is quantised, perhaps we could use time
quanta since the big bang, with the high and low order bits deleted.
But now there appears to be some doubt there was a big bang after all.
We will have to pick an arbitrary starting point, perhaps the adoption
of the new calendar.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-1-11 4:21:00 |
Top |
java-programmer >> Handling of DST in java
On Tue, 10 Jan 2006 13:57:47 -0500, Eric Sosman <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
> Roedy, I think you've got something -- and if you'll
>let me smoke some, too, I won't rat to the narcs.
I consider that sort of crack unacceptably rude, though I notice
people using them quite casually without obvious malice.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2006-1-11 4:27:00 |
Top |
java-programmer >> Handling of DST in java
Roedy Green wrote On 01/10/06 15:16,:
> On Tue, 10 Jan 2006 13:57:47 -0500, Eric Sosman <email***@***.com>
> wrote, quoted or indirectly quoted someone who said :
>
>
>> Come to think of it, who really needs a count of
>>years any more?
>
>
> At some point that will have to happen. Years are a very earth-centric
> measure, hardly suitable for a civilisation spanning many worlds.
>
> If someone discovers time is quantised, perhaps we could use time
> quanta since the big bang, with the high and low order bits deleted.
>
> But now there appears to be some doubt there was a big bang after all.
> We will have to pick an arbitrary starting point, perhaps the adoption
> of the new calendar.
Don't invent Yet Another Zero; stick with existing precedent:
http://www3.sympatico.ca/n.rieck/docs/calendar_time_y2k_etc.html#nov-17-1858
--
email***@***.com
|
| |
|
| |
 |
Raymond DeCampo

|
Posted: 2006-1-11 4:36:00 |
Top |
java-programmer >> Handling of DST in java
Roedy Green wrote:
> On 10 Jan 2006 18:44:28 GMT, email***@***.com (Stefan Ram)
> wrote, quoted or indirectly quoted someone who said :
>
>
>> I agree. It just seems to be an attempt to show to power of
>> the government, "look, we can change the run of the time!" or
>> "Look, we can make completely idiotic rules, still you have to
>> live by them."
>
>
> Local time is a concept on its way out. With netmeetings across the
> globe, you have to arrange your meeting in some common global base
> time, be it UTC , EST or head office time.
>
> Similarly for satellite broadcasts across time zones.
>
> As travel speeds up, we may find even meetings between in and out of
> towners arranged in some common base -- NOT local time.
>
> When a politician meddles with the rules for time, it creates a
> headache for anyone who has a payroll system, or anything that runs 24
> hours.
>
> I first became aware of the problem back in the 1970s. To my surprise,
> "war time" as it was originally called was quite chaotically employed,
> using an offset up to 5 hours, with every community separately making
> up their own rules about when to kick in and out each year.
>
> Railroads refused to play and published their schedules in standard
> time. I suppose with computers they have now relented.
>
> I like the idea of keeping correlation between time and position of
> the Sun in the sky. Pretending the sun in irrelevant to man's
> activity is just arrogance. It enforces the idea that man is not an
> animal with the same environmental limitations that face all animals.
>
> Java wisely stores all dates in UTC and considers timezone merely a
> display quirk, not something inherent in the measurement.
>
The sun is in fact a prime motivator for daylight saving time.
Politicians are not simply meddling with time to display their power.
It has been shown that daylight saving time results in less energy
consumption. I'll leave it as an exercise to the reader why that is a
good thing. :-)
Ray
--
This signature intentionally left blank.
|
| |
|
| |
 |
Luc The Perverse

|
Posted: 2006-1-11 4:46:00 |
Top |
java-programmer >> Handling of DST in java
"Stefan Ram" <email***@***.com> wrote in message
news:email***@***.com...
> Roedy Green <email***@***.com> writes:
>>I think it is a nutty idea. It creates two goofy anomalies each year
>>-- a missing hour and an hour lived twice. Leave the time alone and
>>just declare different summer and winter business hours.
>
> I agree. It just seems to be an attempt to show to power of
> the government, "look, we can change the run of the time!" or
> "Look, we can make completely idiotic rules, still you have to
> live by them."
>
> In 2005, US-president Bush signed a paper to extend DST by
> four weeks in the USA (starting in 2007), and to make life
> even more complicated by adding another rule modification ...
>
> There is an "international movement" against it, the German
> website is
>
> http://www.initiative-sonnenzeit.de/
I really don't think Bush gives a shit what his people think let alone
Germans.
:)
|
| |
|
| |
 |
Oliver Wong

|
Posted: 2006-1-11 5:31:00 |
Top |
java-programmer >> Handling of DST in java
"Eric Sosman" <email***@***.com> wrote in message
news:dq103b$86c$email***@***.com...
>
> Come to think of it, who really needs a count of
> years any more? We'll just get all of civil society to
> switch to counting milliseconds since, since, well I
> guess we'll just call it Millisecond Zero. "You are
> charged with serving alcohol to a person under the age
> of 568036800000, for which you could be sent to prison
> for as long as 126230400000. How do you plead?" See
> how much simpler things are when you don't need to
> specify which of a multitude of confusing units is
> meant?
I think it would make more sense to make the "second" the basic unit of
time, just like the "meter" is the basic unit of length, or the "litre" is
the basic unit of volume. And so the judge would probably not say "under the
age of 568036800 seconds", but rather "under the age of 568 megaseconds".
But then again, 568 megaseconds seems rather arbitrary, and would only
exist for historical reasons related to the drinking age previously being
based on the unit of year. So with these new units, probably for
convenience, the drinking age would be amended to 500 megaseconds, or 600
megaseconds or some other round number (500 Ms is approximately 15 years and
10 months, 600 Ms is approximately 19 years).
For a sense of scale with respect to life expectancy, 80 years is about
2.5 gigaseconds.
- Oliver
|
| |
|
| |
 |
ram

|
Posted: 2006-1-11 6:15:00 |
Top |
java-programmer >> Handling of DST in java
Raymond DeCampo <email***@***.com> writes:
>It has been shown that daylight saving time results in less
>energy consumption.
"less" in relation to what?
Leaving the time zone unmodified, but shifting the start and
end time of work might have the same effect.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-1-11 7:07:00 |
Top |
java-programmer >> Handling of DST in java
On Tue, 10 Jan 2006 15:27:29 -0500, Eric Sosman <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
> Don't invent Yet Another Zero; stick with existing precedent:
the old Julian astronomer's calendar epoch is a good one. It does not
have religious connotations.
Another than might just evolve out of Java is millis since 1970 since
programmers learn it as a side effect of debugging date code.
These probably is a defacto one that all the satellite and
astronomical folk use for high precision work.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2006-1-11 19:55:00 |
Top |
java-programmer >> Handling of DST in java
Eric Sosman wrote:
> > I think it is a nutty idea. It creates two goofy anomalies each year
> > -- a missing hour and an hour lived twice. Leave the time alone and
> > just declare different summer and winter business hours.
> > Non-compliance would help spread rush hour.
>
> Why stop there? Get rid of this silly business of
> time zones and just run the entire world on UTC.
The reason for stopping there is that DST is an outdated hack that could easily
/be/ dropped, whereas any the other options you mention would require that real
people adapt to it (which ain't going to happen -- obviously).
OTOH, if you are genuinely want to see peoples' local intuitions about
times-of-day reflected in the clock, why don't we go back to the idea that the
length of an hour/minute/second is dependent on the length of the local
day/night (as used to be the case) ? That, very people-centric, idea was
dropped several hundred years ago, but only because they didn't have the
technology. Nor had they (I think) the sophistication to recognise that they
could use two clocks, one for scientific/global purposes (such as astronomy and
international trade) and another for local purposes. We do now (for both).
So the hour from midnight to 1 AM in Aberdeen should be longer than the
corresponding hour in London (at this time of year -- the reverse in summer). I
admit that that would introduce some small problems (for instance the local
speed limit would change with the time of day ;-), but nothing that couldn't
easily be dealt with.
-- chris
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2006-1-12 2:15:00 |
Top |
java-programmer >> Handling of DST in java
Roedy Green wrote On 01/10/06 15:20,:
> On Tue, 10 Jan 2006 13:57:47 -0500, Eric Sosman <email***@***.com>
> wrote, quoted or indirectly quoted someone who said :
>
>
>> Roedy, I think you've got something -- and if you'll
>>let me smoke some, too, I won't rat to the narcs.
>
>
> I consider that sort of crack unacceptably rude, though I notice
> people using them quite casually without obvious malice.
My tongue was quite firmly in my cheek, as I thought
would be clear from the rest of my message. If the
resulting grimace offended you, I apologize.
It's been observed more than once that although Usenet
is a good channel for words, it's a poor communicator of
"attitude."
--
email***@***.com
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2006-1-12 2:36:00 |
Top |
java-programmer >> Handling of DST in java
Eric Sosman wrote:
> My tongue was quite firmly in my cheek, as I thought
> would be clear from the rest of my message.
It was transparently clear.
-- chris
|
| |
|
| |
 |
Alex Buell

|
Posted: 2006-1-12 3:49:00 |
Top |
java-programmer >> Handling of DST in java
On Tue, 10 Jan 2006 20:20:47 GMT Roedy Green
<email***@***.com> waved a wand and this
message magically appeared:
> > Roedy, I think you've got something -- and if you'll
> >let me smoke some, too, I won't rat to the narcs.
>
> I consider that sort of crack unacceptably rude, though I notice
> people using them quite casually without obvious malice.
What's the matter, someone take away your sense of humour?
--
http://www.munted.org.uk
Anyone that thinks an imaginary deity is going to protect them against
earthquakes and hurricanes needs psychiatric help.
|
| |
|
| |
 |
Raymond DeCampo

|
Posted: 2006-1-12 4:27:00 |
Top |
java-programmer >> Handling of DST in java
Stefan Ram wrote:
> Raymond DeCampo <email***@***.com> writes:
>
>>It has been shown that daylight saving time results in less
>>energy consumption.
>
>
> "less" in relation to what?
I think that it is clear that the statement above compares daylight
saving time to the lack of daylight saving time.
>
> Leaving the time zone unmodified, but shifting the start and
> end time of work might have the same effect.
Perhaps, but that is not something the government can easily legislate
nor enforce. (Do you really want the time police checking to see if you
are working an hour later?) Changing the wall clock time is the easiest
way to get people to actually observe the change.
There is nothing sacred about the time zone. It has always been under
the purview of government. In China, there should be about five time
zones by geographical standards, but there is only one. In the U.S.,
the Eastern time zone is about twice as big as it should be.
Ray
--
This signature intentionally left blank.
|
| |
|
| |
 |
ram

|
Posted: 2006-1-12 4:52:00 |
Top |
java-programmer >> Handling of DST in java
Raymond DeCampo <email***@***.com> writes:
>Perhaps, but that is not something the government can easily
>legislate nor enforce. (Do you really want the time police
>checking to see if you are working an hour later?)
Something like this is done here for the closing-time of
stores. So, since the government already enforces
opening-times and closing-times of stores, they could change
these and they could change to times for schools, universities
and their own agencies. Some other institutions then might
follow.
>There is nothing sacred about the time zone.
It is only that, given two time stamps of the legal time for
a location in Germany, like
2005-07-10T21:38:10 and
1960-07-10T21:38:13
it would be a typical programming task to write a routine
that can calculate the difference between them in seconds.
And this would be much more easy, without the need to have
to find out all details of regulations for DST in Germany.
After WWII, in Germany, there were several different zones
controlled by different countries and some details for the DST
differed between these zones. In one zone, there was a special
DST with two hours added for the mid of summer. Then there are
reports that there were years with DST even in winter. And so
on.
All these special regulations make it very difficult to
write such a routine.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Anyone seen this problemMaybe I am being stupid, but I am having difficulty getting mouse events
from a custom JComponent. At this point I have put an instance of a subclass
of JComponent in a JScrollPane and placed it in the center of a
BorderLayout. I then added a mouse listener to the subclass of JComponent,
traced through the code to make sure I am acutally adding the listener, but
my mouseClicked(), mousePressed() and mouseReleased() methods on my listener
class are not called. Any one seen this problem before.
- 2
- Need help creating a program to create sudukoStill a little rough at this language but i need to create a program
for my class. Was wanting to create a java program that makes sudukos.
It doesn't need a GUI or anything like that just ouput to a txt file
ot to the screen. I would appreciate any help or direction.
- 3
- JspException in custom tagHello,
Can someone show me the error of my ways.....
I have a custom tag 'public int doStartTag() throws JspException' from
which a JspException is thrown. The exception is forwarded to an JSP
error page and from there I want to (eventually) shove the contents of
the exception into a javabean.
My javabean is set up as follows:
public class errorBean
{
Throwable errorObject = null;
String errorMessage = null;
public void setErrorObject(Throwable errorObject)
{
this.errorObject = errorObject;
errorMessage = errorObject.getMessage();
}
public String getErrorMessage()
{
return errorMessage;
}
} //errorBean
My JSP error page looks like:
<%@ page isErrorPage="true" %>
<html>
<body>
<jsp:useBean id="errorBean" class="errorBean"/>
<jsp:setProperty name="errorBean" property="errorObject"
value="${pageContext.errorData.throwable}"/>
The error message is <jsp:getProperty name="errorBean"
property="errorMessage"/>
</body>
</html>
When I throw an exception like 'throw new JspException("Hello World")'
in my custom tag,
everything seems to work i.e. "Hello World" shows up in my Mozilla &
Netscape browser.
When I throw an exception like 'throw new JsPException("Hello
World",throwableObject)
where throwableObject subclasses Throwable, I get a 'http status 500'
error, but the browser clearly displays as part of a stack trace (?)
the exception "Hello World" as well as the root cause.
Why would this work in one case ('throw new JspException("Hello
World")' and other
('throw new JsPException("Hello World",throwableObject)) fail to
display "Hello World"?
Thnaks for any help.
- 4
- Help with writing simple parser for HTML/XMLI'm having trouble getting started with coding a simple parser and prototype
for my application.
The parser needs to parse HTML & XML pages to strip the tags and return just
the data. Ive read thru sevral java refeerence books but seem to be having
trouble getting started with the code.
I'd be gratefull for a push in the right direction.
thanks
sal
ps this is my final year University Computer Science project
for more details on the project
http://www.mellowmoose.org/project.html
- 5
- XML call XSL that calls xml through document() elementHello,
I am trying to create an XML document on the fly that sends some
parameters to an xsl document which calls the correct xml document that
corresponds to the parameters.
I reference the xsl document:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="web-primary.xsl"?>
I am just trying to hardcode the request to prove that this is possible
for the time being so the parameters are already in the xsl that will
eventually be variables.
but I am unsure what else to include in the first XML file to make the
call to the web-primary.xsl????? My XSL is complete and the
corresponding XSL files are complete.
The xsl doc has a document element that calls the correct xml file that
contains the data.
My reason for doing all of this is because Firefox will not allow me to
go to a remote xml file from the server so I want the browser to do the
work of getting the remote xml file. If you have a better way of doing
this, please let me know.
thx.
- 6
- Java application for GPRS connectionI need to manage the GPRS connection (set up the connection, connect
and disconnect) in a symbol handheld device with Windows Mobile 5. I'm
developing this application with Java 1.3 and using IBM J9 as jvm. How
can I deal with this?
Many Thanks
- 7
- 8
- Did anyone upload file to php server by using swing applet before? Need help!!!Hi,
I need a help. Recently I wrote a swing applet for uploading files to
php server. It seems that everything is fine now. I can get the exactly
same size files in the server. For text file, there is no any problem
to be openned. But for image and moive files (such as .jpeg, .gif .mov
and etc.), those files can not be openned after they are uploaded to
sever even the size is exactly the same as orignal files.
I think that it should be caused by "Content-Type".
For testing, I change my Content-Type to "image/gif" to send gif files.
However, the problem is still there. Now, I have no idea about this
problem. Could any one give me a favor? Thanks in advance!!!
I attached the code related to connection and sending data here for
your review.
public boolean upload() throws Exception{
boolean done = false;
String file_name = file.getName();
String file_data = readFile();
StringBuffer response = new StringBuffer("");
OutputStream os = null;
BufferedReader in = null;
HttpURLConnection conn = null;
try{
URL serverURL = new URL(url);
// connect to server
URLConnection uc = serverURL.openConnection();
conn = (HttpURLConnection) uc;
conn.setAllowUserInteraction(true);
conn.setInstanceFollowRedirects(true);
// set connection as POST
conn.setRequestMethod("POST");
conn.setDoOutput(true); // turns it into a post
// setup headers
conn.setRequestProperty(
"Content-Type",
"multipart/form-data; boundary=" + CONTENT_BOUNDARY);
conn.setRequestProperty("Accept-Language", "en-us");
conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
conn.setRequestProperty("CACHE-CONTROL", "no-cache");
os = conn.getOutputStream();
String request =
"--"
+ CONTENT_BOUNDARY
+ "\r\n"
+ "Content-Disposition: form-data; name=\"upfile\"\r\n\r\n"
+ file_name
+ "\r\n"
+ "--"
+ CONTENT_BOUNDARY
+ "\r\n"
+ "Content-Disposition: form-data; name=\"upfile\"; filename=" +
file_name
+ "\r\nContent-Type: multipart/form-data\r\n\r\n"
+ file_data //file is read into a string here, is it OK? But no
other choose.
+ "\r\n"
+ "--"
+ CONTENT_BOUNDARY
+ "\r\n";
System.out.println("DEBUG: Sending the following request:\n\r" +
request);
System.out.println("DEBUG: Sending the post request...\n\r");
os.flush();
os.write(request.getBytes(), 0, request.getBytes().length);
os.flush();
in = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
// closing connections
in.close();
in = null;
os.close();
os = null;
conn.disconnect();
conn = null;
done = true;
- 9
- Java securityI havean applet that connects to Oracle osing the thin client. It
works when run from IDE. When I try to load it into a web browser I
get
java.security.AccessControlException: access denied
(java.util.PropertyPermission oracle.jserver.version read)
What's up?
- 10
- googling google persistance using google apiI've been over to <http://www.google.com/apis/> and downloaded
GoogleAPIDemo.java, which is much simpler than expected. I'd like to
save the query results to a file. I'm thinking that each query result
could almost be apended to an XML file, this seems the most natural and
easiest approach.
However, I'm, err, not finding anything on google about doing so. I
know that the demo uses SOAP and I know that I know nothing about SOAP
and have no real interest in learning about SOAP at this time.
However, I believe that SOAP is good for communicating with databases,
yes?
I've been over to <http://www.w3.org/TR/soap/> which led me to:
Abstract
SOAP is a lightweight protocol for exchange of information in a
decentralized, distributed environment. It is an XML based protocol
that consists of three parts: an envelope that defines a framework for
describing what is in a message and how to process it, a set of
encoding rules for expressing instances of application-defined
datatypes, and a convention for representing remote procedure calls and
responses. SOAP can potentially be used in combination with a variety
of other protocols; however, the only bindings defined in this document
describe how to use SOAP in combination with HTTP and HTTP Extension
Framework.
which all sounds very nice but it seems like I'd have to buy a book to
get it working. There's lightweight, then there's lightweight, if you
get my meaning, and I think that SOAP is bit not-lightweight for my
purposes. I would like an XML file with something like (please forgive
my atrocious XML):
<result>
<www.whatever.com />
<some text here />
</result>
<result>
<www.foo.com />
<different text here />
</result>
<result>
<www.bar.com />
<text on bar here />
<result>
Or something along those lines, which mirrors whatever google gives the
demo. However, I can't find something ready-made for creating such a
file, which surprises me. I'm looking for something relatively easy
which I can put together with the demo to save some results to file,
such that the results can be put into a database at a later time.
However, my google results are less than stellar. How do people
save/persist their google results?
My personal computer is broken at the moment, so this all hypothetical.
I haven't compiled the demo yet, never mind modifying it.
thanks,
Thufir
- 11
- benchmarks? java vs .netJon Skeet [C# MVP] wrote:
> On Jun 3, 4:39 pm, Jon Harrop <email***@***.com> wrote:
>> FWIW, F#/Mono is 3x slower than F#/.NET on the SciMark2 benchmark. I'd like
>> to know how performance compares between these platforms for parallel code.
>
> If Razii is genuinely comparing Java with Mono (I haven't looked at
> any of the figures) it's a silly test to start with (unless you're
> specifically interested in Mono, of course). The vast majority of C#
> code runs on .NET rather than Mono - and while I applaud the Mono
> team's work, I seriously doubt that it has quite has much effort going
> into it as Microsoft is putting into .NET. I'd expect .NET to
> outperform Mono, and on microbencharks like these the difference could
> be quite significant in some cases.
I have frequently seen a x2 factor between MS .NET 2.0 and Mono 1.2 !
Comparing with Mono is too easy.
Arne
- 12
- Where in the language is ".class"?Where in the Java language specification or API is the idiom
"Foo.class" defined? It's not an attribute of any class I can find,
and I can't find it in the core language specification.
Thanks.
- 13
- the best way to store program setupHello,
What is the best way to store program configuration settings? Each
class has its own parameters that might be useful just for current
class. There are some parameters that might be useful in whole
program. Probably main class could have confifiguration for whole
program, but how I could access them from class that is inside main
class?
Thank you
- 14
- Filechooser appearanceI am using Netbeans. I need a JFileChooser to pop up in it's own
window, but i'm not sure how to make this happen. i'm new to java gui
programming. could someone please point me in the direction of (or
just provide) a clear-cut example of how to do this, as I can' seem to
find one?
- 15
- card shuffling errorI am relatively new to java programming and I am working on a card
project for school. I had finished and tested every method with error
in my Deck class. However, in the time it took to pick up dinner it is
now producing errors. I would greatly appreciate anyone input and help.
This is the error that is produce when invoking the shuffle method.
java.lang.IndexOutOfBoundsException: Index: 235, Size: 51
at java.util.ArrayList.RangeCheck(ArrayList.java:546)
at java.util.ArrayList.get(ArrayList.java:321)
at Deck.swap(Deck.java:176)
at Deck.shuffle(Deck.java:129)
public class Deck
{
/** The number of cards in a deck */
public static final int DECK_SIZE = 52;
/** The number of times to shuffle */
public static final int TIMES_TO_SHUFFLE = 1000;
private ArrayList deck; // a deck of cards
/**
* Constructor for objects of class Deck
*/
public Deck()
{
deck = new ArrayList();
newDeck();
}
/**
* Load a new deck with all DECK_SIZE cards
*/
public void newDeck()
{
if (deck.size() > 0){
deck = null;
}
else{
//Hearts
deck.add(new Card("Ace","Hearts",11));
deck.add(new Card("Two","Hearts",2));
deck.add(new Card("Three","Hearts",3));
deck.add(new Card("Four","Hearts",4));
deck.add(new Card("Five","Hearts",5));
deck.add(new Card("Six","Hearts",6));
deck.add(new Card("Seven","Hearts",7));
deck.add(new Card("Eight","Hearts",8));
deck.add(new Card("Nine","Hearts",9));
deck.add(new Card("Ten","Hearts",10));
deck.add(new Card("Jack","Hearts",10));
deck.add(new Card("Queen","Hearts",10));
deck.add(new Card("King","Hearts",10));
//Diamonds
deck.add(new Card("Ace","Diamonds",11));
deck.add(new Card("Two","Diamonds",2));
deck.add(new Card("Three","Diamonds",3));
deck.add(new Card("Four","Diamonds",4));
deck.add(new Card("Five","Diamonds",5));
deck.add(new Card("Six","Diamonds",6));
deck.add(new Card("Seven","Diamonds",7));
deck.add(new Card("Eight","Diamonds",8));
deck.add(new Card("Nine","Diamonds",9));
deck.add(new Card("Ten","Diamonds",10));
deck.add(new Card("Jack","Diamomds",10));
deck.add(new Card("Queen","Diamonds",10));
deck.add(new Card("King","Diamonds",10));
//Spades
deck.add(new Card("Ace","Spades",11));
deck.add(new Card("Two","Spades",2));
deck.add(new Card("Three","Spades",3));
deck.add(new Card("Four","Spades",4));
deck.add(new Card("Five","Spades",5));
deck.add(new Card("Six","Spades",6));
deck.add(new Card("Seven","Spades",7));
deck.add(new Card("Eight","Spades",8));
deck.add(new Card("Nine","Spades",9));
deck.add(new Card("Ten","Spades",10));
deck.add(new Card("Jack","Spades",10));
deck.add(new Card("Queen","Spades",10));
deck.add(new Card("King","Spades",10));
//Clubs
deck.add(new Card("Ace","Clubs",11));
deck.add(new Card("Two","Clubs",2));
deck.add(new Card("Three","Clubs",3));
deck.add(new Card("Four","Clubs",4));
deck.add(new Card("Five","Clubs",5));
deck.add(new Card("Six","Clubs",6));
deck.add(new Card("Seven","Clubs",7));
deck.add(new Card("Eight","Clubs",8));
deck.add(new Card("Nine","Clubs",9));
deck.add(new Card("Ten","Clubs",10));
deck.add(new Card("Jack","Clubs",10));
deck.add(new Card("Queen","Clubs",10));
deck.add(new Card("King","Clubs",10));
}
}
/**
* Add a single card to the deck.
* @param a Card object
*/
public void addCard(Card newCard)
{
// add a card to the deck
deck.add(newCard);
}
/**
* Shuffle the deck. This involves selecting random pairs of
* cards and swapping them, the number of times to swap determined
* by the constant TIMES_TO_SHUFFLE.
*/
public void shuffle()
{
//Zero the deck vector
deck.removeAllElements();
int index1 ,index2;
for (int i = 0; i < DECK_SIZE ; i++) {
index1 = (int)(Math.random()*TIMES_TO_SHUFFLE);
index2 = (int)(Math.random()*TIMES_TO_SHUFFLE);
swap (index1, index2);
}
}
/**
* Display the entire contents of the deck. Not used in the
* game but useful for debugging.
*/
public void showDeck()
{
Iterator it = deck.iterator();
while(it.hasNext()) {
Card currentCard = (Card) it.next();
System.out.println(currentCard);
}
}
/**
* Remove the top card from the deck.
* @return the Card object removed or null if there is nothing in
the deck.
*/
public Card takeCard()
{
int index = 0;
if (index >= deckSize()) {
return null;
}
else{
return (Card) deck.remove(0);
}
}
/**
* Return size of deck
*/
public int deckSize()
{
return deck.size();
}
/**
* Card Swap method
*/
public void swap(int index1, int index2) {
Card temp = (Card)deck.get(index1);
deck.set(index1, deck.get(index2));
deck.set(index2, temp);
}
/**
* Methods returns card index and card description - testing
purpose
*/
public void displayCardIndex()
{
for (int index = 0; index < deckSize(); index++)
{
System.out.println("Index: " + index + " Card : " +
deck.get(index));
}
}
}
|
|
|