William Gibson Books    www.williamgibsonboard.com    www.williamgibsonboard.com  Hop To Forum Categories  Random Thoughts    Basic computer assistance required, please.
Page 1 ... 70 71 72 73 74 75 76 ... 102
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Member
Picture of ArkanGL
Online Status For 33024673
Posted Hide Post
If anyone has a clean trick to calculate a "30 days/end of the months" date with Java, I'm interested.

I'm working on a billing application, and I hate its guts.


_____________________________
Albert's path is a strange and difficult one.
 
Posts: 19947 | Location: Republic of Heaven | Registered: March 10, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Newro
Posted Hide Post
Now back in college we learned a mathematical formula that will compute leap years ... but I would try this:
GregorianCalendar calendar = new GregorianCalendar();
calendar.getActualMaximum(GregorianCalendar .MONTH);


In the past, I also used to create an Calendar object, and catch the exception to do my validation.

Not the most stylish thing to do, but lazy.



___________________________________________________________
"The best way to predict the future is to invent it." Alan Kay, 1971.
 
Posts: 4306 | Location: Cyberspace | Registered: January 09, 2004Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of ArkanGL
Online Status For 33024673
Posted Hide Post
This is how I ended up doing it :

We start with 'initialDate'.
We want to calculate the expiration date, based on the X days/end of month rule.

X can be 30, 60 or 90

The rule is :
To obtain the final date, add the specified number of days, and go to the end of the month you obtain.
Except if your inital date is on the 1st a month (then, one less month should be added).

Calendar cal = GregorianCalendar.getInstance();
cal.setTime(initialDate);
        
// add the number of months (30/30 , 60/30 or 90/30)
int monthsToAdd = daysToAdd / 30;

// use a second calendar
// (to check if we're on the first day of the month)
Calendar calTest = GregorianCalendar.getInstance();
calTest.setTime(initialDate);
calTest.set(Calendar.DAY_OF_MONTH, 1);

if ( calTest.compareTo(cal) == 0 ) {
    // if the date is the first day of the month, then one less month should be added
    monthsToAdd--;
}
cal.add(Calendar.MONTH, monthsToAdd);
        	
// go to the end of the month
int nbDaysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, nbDaysInMonth);


cal.getTime() now gives the final date.


_____________________________
Albert's path is a strange and difficult one.
 
Posts: 19947 | Location: Republic of Heaven | Registered: March 10, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of psyclone
Posted Hide Post
quote:
Originally posted by ArkanGL:
If anyone has a clean trick to calculate a "30 days/end of the months" date with Java, I'm interested.

I'm working on a billing application, and I hate its guts.


This is not basic computer assistance! It's asking us to do the job you are paid for! Smile


 
Posts: 1329 | Registered: August 19, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of shake
Posted Hide Post
quote:
Originally posted by psyclone:
quote:
Originally posted by ArkanGL:
If anyone has a clean trick to calculate a "30 days/end of the months" date with Java, I'm interested.

I'm working on a billing application, and I hate its guts.


This is not basic computer assistance! It's asking us to do the job you are paid for! Smile
I don't see the problem here. What's wrong with that?
 
Posts: 3883 | Location: Mountain View,CA,USA | Registered: September 30, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of ArkanGL
Online Status For 33024673
Posted Hide Post
quote:
I don't see the problem here. What's wrong with that?


I don't see any problem here either.
There's nothing wrong with it.

Community-based development is where it's at.


_____________________________
Albert's path is a strange and difficult one.
 
Posts: 19947 | Location: Republic of Heaven | Registered: March 10, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Archie
AIM: Online Status For Tbrodhead1225
Posted Hide Post
quote:
Originally posted by psyclone:

quote:
Originally posted by ArkanGL:
If anyone has a clean trick to calculate a "30 days/end of the months" date with Java, I'm interested.

I'm working on a billing application, and I hate its guts.


This is not basic computer assistance! It's asking us to do the job you are paid for!


it's resource sharing. nothing wrong with that at all.


www.ianthomascomics.blogspot.com

Can I bone Kai and Butchie know my Father, instead?
 
Posts: 3862 | Location: Pittsburgh | Registered: June 21, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of electricdragon/ madevilbeats
AIM: Online Status For elektrikdrag0n
Posted Hide Post
See, if Arkan was really sneaky, he would have just started a code challenge thread with the above post as the initial problem challenge. Then he would have gotten back a larger set of possible solutions and could have Big O'd each one to find the one that worked best for his program....


***************************************************
* MEB_Registered: 20122002
 
Posts: 3321 | Location: Austin, Tejas | Registered: May 02, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of psyclone
Posted Hide Post
Nothing "wrong" with that. But perhaps there should be a thread called "I'm a lazy bum. Can you solve this problem for me?" Smile



PS. I'm kidding, guys.


 
Posts: 1329 | Registered: August 19, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of shake
Posted Hide Post
you must not work in software.
 
Posts: 3883 | Location: Mountain View,CA,USA | Registered: September 30, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of UberDog
AIM: Online Status For ubercanis
Posted Hide Post
quote:


This is not basic computer assistance! It's asking us to do the job you are paid for! Smile
What does he get paid for?


---
"Your enthusiasm for sporting events reveals nothing about the human condition except by way of irony."
 
Posts: 9520 | Location: 410 A.D. | Registered: February 20, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of psyclone
Posted Hide Post
quote:
Originally posted by UberDog:
quote:


This is not basic computer assistance! It's asking us to do the job you are paid for! Smile
What does he get paid for?


quote:
I'm working on a billing application, and I hate its guts.


It could be charity work!


 
Posts: 1329 | Registered: August 19, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of shake
Posted Hide Post
Doesn't matter.
 
Posts: 3883 | Location: Mountain View,CA,USA | Registered: September 30, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of UberDog
AIM: Online Status For ubercanis
Posted Hide Post
quote:
Originally posted by psyclone:
quote:
Originally posted by UberDog:
quote:


This is not basic computer assistance! It's asking us to do the job you are paid for! Smile
What does he get paid for?


quote:
I'm working on a billing application, and I hate its guts.


It could be charity work!
I mean in general. He makes billing applications in general?


---
"Your enthusiasm for sporting events reveals nothing about the human condition except by way of irony."
 
Posts: 9520 | Location: 410 A.D. | Registered: February 20, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of shake
Posted Hide Post
why does it matter?
 
Posts: 3883 | Location: Mountain View,CA,USA | Registered: September 30, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of UberDog
AIM: Online Status For ubercanis
Posted Hide Post
It matters to me, and if it matters to me, it matters to the world!


---
"Your enthusiasm for sporting events reveals nothing about the human condition except by way of irony."
 
Posts: 9520 | Location: 410 A.D. | Registered: February 20, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of psyclone
Posted Hide Post
quote:
Originally posted by shake:
why does it matter?

Why does anything matter?


 
Posts: 1329 | Registered: August 19, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of shake
Posted Hide Post
Start a thread and find out.
 
Posts: 3883 | Location: Mountain View,CA,USA | Registered: September 30, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of electricdragon/ madevilbeats
AIM: Online Status For elektrikdrag0n
Posted Hide Post
anyone know any good data recovery tools? I put an old hard drive in an enclosure, hooked it up to my system over USB and it showed up fine on my Mac. it was already partitioned into three, and i moved some old data I'd like to keep onto two of them, and then attempted to erase the first partition, which was Fat32.

the intent was to change the format of that partition to the Apple OS extended but what happened was it reported failure and messed up the MBR or something because now none of the partitions are showing. i doubt it killed the data but i can'recall how to reset the part of the drive that stores the partition data stuff and google is spooling out endless streams of useless results for me at the moment.....


***************************************************
* MEB_Registered: 20122002
 
Posts: 3321 | Location: Austin, Tejas | Registered: May 02, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of heavyboots
Posted Hide Post
I believe Data Rescue II will entice you with the ability to see the names of the files they think they can recover, but not the actual data.

And pdisk is the Apple CLI partitioning tool, iirc. If all else fails, you might try partitioning them exactly the same sizes they were with no data in them and then recovering from the "empty" partitions, which hopefully still have all your data--just no directory record of it. But save that one for dead last for obvious reasons...
 
Posts: 4697 | Registered: January 14, 2003Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community Page 1 ... 70 71 72 73 74 75 76 ... 102 
 

William Gibson Books    www.williamgibsonboard.com    www.williamgibsonboard.com  Hop To Forum Categories  Random Thoughts    Basic computer assistance required, please.

© Copyright 2005, AuthorsOnTheWeb.com