Kristol Crawley

Greenhorn
+ Follow
since Sep 17, 2003
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kristol Crawley

Hi,

If I already have a file somewhere that I just want to attach to an email, do I still have to read it in to write it out? When I tried doing it that way it gives me a null pointer when it's writing the data. When I check the file it's wiped all the data. I'm not sure what I'm doing wrong.

String pdf2Name = getPage2Dir();FileOutputStream pdfFile = new FileOutputStream(pdf2Name);
pdfFile.write(getStreamInfo().toByteArray());
pdfFile.close();
18 years ago
I am completely lost with this thing! I have to compare 2 dates and figure out if they're within x amount of hours. I'm testing with 2. I have to set the timezone to the input timezone. I create 2 gregorian dates to whatever the input timezone is. Then I add the hours to the comparison date.
My problem is that it's printing the timezone as cst (what I'm testing with) but the time is calculating in est. Also, it looks like the requested date also gets added. They're 2 separate dates so I don't see how one value could be affecting the other.
Can anyone see what I'm doing wrong with this?
This is the output:
Initial Set. current: Thu Feb 05 20:55:15 EST 2004 req: Thu Feb 05 20:55:15 EST 2004
Before set current: Thu Feb 05 22:55:15 EST 2004
Requested after reset Thu Feb 05 19:00:15 EST 2004
Now the biggee, is it within 2 hours? 1
Interactive Session Ended
This is the code:
//Converts GMT to CST
String[] ids = TimeZone.getAvailableIDs(-6 * 60 * 60 * 1000);
SimpleTimeZone cst = new SimpleTimeZone(-6 * 60 * 60 * 1000, ids[0]);
//Calculate the day light savings time changes
cst.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
cst.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

GregorianCalendar varCurrentCal = new GregorianCalendar(cst);
Calendar varReqCal = new GregorianCalendar(cst);
System.out.println("Initial Set. current: " + varCurrentCal.getTime() + " req: " + varReqCal.getTime());

//requested is military format, use HOUR_OF_DAY
//.add forces recalculation
varCurrentCal.add(Calendar.HOUR_OF_DAY, 2);
//System.out.println("Added 2 hours to current: " + varCurrentCal.getTime());

//requested date/time entered
int year = 2004;
int month = 02;
int day = 05;
int hour = 18;
int minute = 00;

System.out.println("Before set current: " + varCurrentCal.getTime());
varCurrentCal.getTime();

varReqCal.set(year,(month -1),day,hour,minute);
varReqCal.getTime();
System.out.println("Requested after reset " + varReqCal.getTime());
int delThis = varCurrentCal.getTime().compareTo(varReqCal.getTime());
System.out.println("Now the biggee, is it within 2 hours? " + delThis);
18 years ago
Hiya!!
Can I create an xml file from a db call in java? I keep reading about parsing xml into java but I don't see it the other way around? I have login data stored in a table, I want to create an xml file from this data and use it to create the user's menu. The company I work for has multiple customers they work with, our groups have access to some, all, none of these customers in different capacity (admin, order entry, etc..) At the moment we have a new menu for each customer and tons of checks for the user's level of access, which customer they're working with etc... It's way too hard to manage at the moment and I was hoping to make it easier.
What I was hoping to do is to build this xml when they login and they'd have it throughout their session. After the logout or expire I'll delete the file. I could keep it around but user levels/access change all the time, I don't want to run the risk of having bad data. Unless I can update the xml for the user, that'd be even better.
BUT, I know nothing about xml and the sites I've gone to so far have been very confusing to say the least. I don't want the solution handed to me, just some guidance in how to go about learning how to do this and if this seems like the right way to go about this.
Thanks for reading the babbling
You may have solved this issue already BUT, on every machine I've ever used (with Windows os) I always have to add this to my classpath:
C:\.;
19 years ago
I figured it'd be messy!
Thank you Jason!
19 years ago
Is it possible to tell if the date is a holiday? I looked through the api for calendar (we're on 1.3.1 btw) and I didn't see anything that looked like it would return that.
19 years ago
I didn't think you could user "=" to compare String vars. Eric, use equals to do a string comparison. If case doesn't matter use equalsIgnoreCase.
Good luck!
19 years ago