2004 IR Help Posted September 2, 2006 Share Posted September 2, 2006 By: Jordon - jordonj Is there a way to change a double to a date? 2004-09-13 12:47 I have a paremter and a field in a table that are declared as double, but they are really dates. Is there a way to convert the double to a date, for print formatting? By: Ralf Weinand - weinanr RE: Is there a way to change a double to a da 2004-09-20 07:25 Hi Jordan, try to convert the double into long and use the constructor new Date(long) to create the Date object. Regards, Ralf By: Andrew McLaughlin - pik0 RE: Is there a way to change a double to a da 2004-09-20 09:19 Why are you converting a double to Date? Perhaps the Field reference should be update? What format is the date being stored? Piko By: Jordon - jordonj RE: Is there a way to change a double to a date? 2004-09-23 06:09 the date is stored as a double, so I wanted to convert it to date for displaying properly; I used toString and concatenated to get what I wanted, but I was just wondering if there was an easier way... By: Andrew McLaughlin - pik0 RE: Is there a way to change a double to a date? 2004-09-23 09:34 Right on. Well here's how: new Date( ( long ) $F{ Date_Column }.doubleValue() ) Piko By: Jordon - jordonj RE: Is there a way to change a double to a date? 2004-09-28 05:44 well, that gave me a date, but not the correct date.... 20040907 came out as Wed Dec 31 23 By: Andrew McLaughlin - pik0 RE: Is there a way to change a double to a date? 2004-09-28 11:31 Ah... I assumed that since the date was a double that it was a serial value. Now I realize that it's just a ymd encoded string. Here's how to convert it: new SimpleDateFormat( "yyyyMMdd" ).parse( "" + $F{ double_date_field } ) That should properly convert the data. Note the "" + in the parse function call is to convert the double to a String. While I'm on it, why do you have the date column defined as a double? Since it's really just year month day, it will work easier if you change it to the String that it is... :) Piko By: Jordon - jordonj RE: Is there a way to change a double to a date? 2004-09-29 09:52 that didn't work either..... java.text.ParseException: Unparseable date: "2.0040907E7" I didn't define the field that way... It's coming from a table defined in our software... By: Andrew McLaughlin - pik0 RE: Is there a way to change a double to a date? 2004-09-29 11:19 Okay, change the field type definition from double to String. Then it will work... :) Piko By: Jordon - jordonj RE: Is there a way to change a double to a date? 2004-09-29 11:57 nope..... found : java.util.Date required: java.lang.String value = (java.lang.String)(new SimpleDateFormat("yyyyMMdd").parse("" + ((java.land.Double)field_EGACDT.getValue()))); any other ideas? By: Andrew McLaughlin - pik0 RE: Is there a way to change a double to a date? 2004-09-29 12:54 You have to change the data type for field_EGACDT to String instead of Double. That's the problem. Piko Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now