Tuesday, May 11, 2004
Working with Dates and stuff
Java is known for its lousy date handling classes java.util.Date and java.util.Calendar. Working with, comparing and displaying dates is, simply put, a bitch.
A more manageable solution might be to store date information (in the database) using a plain long, and use a decorator class to access this information:
A Time-class can also be constructed to represent a special interval such as Day, Month or the dreaded Week (there are actually two week "1" in most Calendar years... which is just plain stupid).
A more manageable solution might be to store date information (in the database) using a plain long, and use a decorator class to access this information:
public class Time implements java.io.Serializable, Comparable {
private long internalTime = 0L;
public Time(long timestamp){
internalType = timestamp;
}
public long getValue(){
return internalType;
}
public static Time valueOf(java.util.Date date){
return new Time(date.getTime());
}
public java.util.Date toDate(){
return new java.util.Date(internalTime);
}
public int compareTo(Object another){
if(another instanceof Time){
return this.internalTime - ((Time)another).internalTime;
}
else { throw new ClassCastException(another+" is not an instance of "+getClass().getName()); }
}
}
A Time-class can also be constructed to represent a special interval such as Day, Month or the dreaded Week (there are actually two week "1" in most Calendar years... which is just plain stupid).
Testing posting through the API
This post is written in VIM and uploaded using the BloggerAPI from a Ruby XML-RPC client.
Coolt indeed!
Coolt indeed!
Monday, May 10, 2004
First wobbly steps into BlogLand
Yupp, I suppose it's time to take a stand and publish all that shit I'm currently pestering my friends and co-workers with...
Don't expect to see daily updates though - I'm still trying to structure the way I'd like to do this.
Don't expect to see daily updates though - I'm still trying to structure the way I'd like to do this.
