|
| |||||||||
| Tags: data types, date, decimal, integer, java, progamming language, string |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| BigDecimal and Date
Hello, I would like to display the month and year of a date in this format: 01/09. The fields "datdeb" in the database is of type BigDecimal. I formatted and got this, 01/70 even if I change the year, it is still 70. What is this can you please explain me. Any help on this will be highly appreciated. Thanks in advance. Last edited by Miles Runner : 07-02-2010 at 02:16 AM. |
|
#2
| |||
| |||
| Re: BigDecimal and Date
Hi, It would be nice if you explain that stores the field datdeb your database, why it is mapped to a BigDecimal and by what method you've formatted. Otherwise burns to doublet seen your results I suspect a problem with formatting of a misuse of Date.getTime that as stated in the javadoc Code: Returns the number of milliseconds since January 1, 1980, 00:00:00 GMT represented by this Date object. |
|
#3
| |||
| |||
| Re: BigDecimal and Date
Hello, This is a part of my code, this part contains the logic of the program. Just have a look at it and if you find any mistake then please help me with that. Code: BigDecimal bgdec = new BigDecimal(tt.get(0).getDebExe().function toString() {
[native code]
}());
Date dt = new Date(bgdec.longValue());
String rf = STRs.dttostring1(dt);
societeForm.setDatdeb(STRs); |
|
#4
| |||
| |||
| Re: BigDecimal and Date
Hello, The Date constructor taking a long as parameter (the one you used), adds that many milliseconds to 01/01/1980. So you're with your method, 108 ms after the start of the day, which explains the result that you (and this is the sensed bp). The date that you start in the base (108) must be analyzed as a string, not a number. So you have no need to go through BigDecimal (which also serve to manipulate real numbers), or anything else. I understand how the date is stored, you should take the last two characters, convert them with Integer.parseInt () -> you'll have this year. Then you take what is left and with the same operation you get the month. |
|
#5
| |||
| |||
| Re: BigDecimal and Date
Hello, The above mentioned is correct, I am with it. But the main point in my opinion, and if you want to move forward is to learn to read the javadoc and not wanting to copy what has been done in another language. Finally for you to see. So, I think you should have a look at the java application programming interface. It will be more helpful to you. |
|
#6
| |||
| |||
| Re: BigDecimal and Date
Hello, I think I have found a solution for this now, this is what i do in my code now , and it works for well for now. Code: String dt ="23/10/2008";
String[] tb = dt.split("/");
String fmt = tb[2]+"/"+ Tab[1]+"/"+ Tab[0]; |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "BigDecimal and Date" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Baseline Column Date automatically updates Finish Date | Adam 1980 | Microsoft Project | 3 | 18-05-2011 07:08 PM |
| Java BigDecimal to Integer | Anthony12 | Software Development | 6 | 11-08-2010 06:09 PM |
| Lag time between Start-Date and Finish-Date | Shahriar N k | Microsoft Project | 5 | 22-01-2009 09:42 PM |
| Dependent start date task with fixed end date | horatio123 | Microsoft Project | 1 | 31-08-2008 08:59 AM |
| Changing start date and creating formula for finish date | Lisa M | Microsoft Project | 2 | 11-09-2006 06:10 PM |