Closed hectorsipe closed 1 year ago
Hi! Convert timestamp to date in Java Let's see the simple example to convert Timestamp to Date in java.
import java.sql.Timestamp;
import java.util.Date;
public class TimestampToDateExample1 {
public static void main(String args[]) {
Timestamp ts = new Timestamp(System.currentTimeMillis());
Date date = new Date(ts.getTime());
System.out.println(date);
}
}
Incredible @sumenkov 👌
Hi,
we have a very old .dbf database and want to use JavaDBF to write new records to the database. The database has an field with the type "DATETIME". This is not supported in JavaDBF as far as I understand. The field has no real function and is empty in most cases. But we cannot alter the type or remove the field because of other programs accessing the database.
Is there a way to just skip the field while adding a record to the database?
Thanks in advance
Florian
Hi,
we have a very old .dbf database and want to use JavaDBF to write new records to the database. The database has an field with the type "DATETIME". This is not supported in JavaDBF as far as I understand. The field has no real function and is empty in most cases. But we cannot alter the type or remove the field because of other programs accessing the database.
Is there a way to just skip the field while adding a record to the database?
Thanks in advance
Florian
the first thing that comes to mind is to just give this field the value NULL be sure to send us the result
Thanks for the quick reply. Sadly its not working. We get the following errors:
The field with the DATETIME Type in the database is called "ERFDATUM"
Java Object ERFDATUM defined as String and just keep the string empty
DBFException: Unsupported writting of field type 14 TIMESTAMP com.linuxense.javadbf.DBFWriter.addRecord(DBFWriter.java:289)
Â
Empty String as null
DBFException: Unknown field type TIMESTAMP com.linuxense.javadbf.DBFWriter.writeRecord(DBFWriter.java:424) com.linuxense.javadbf.DBFWriter.addRecord(DBFWriter.java:298)
Â
Java Object ERFDATUM defined as Date Date as null
DBFException: Unknown field type TIMESTAMP com.linuxense.javadbf.DBFWriter.writeRecord(DBFWriter.java:424) com.linuxense.javadbf.DBFWriter.addRecord(DBFWriter.java:298)
Wer have found the following explanation for "null" not working:
We are in the 'DBFWriter.java' class:
With addRecord() a check of the value to null takes place in the for loop. If the value is null it continues the next field. But in the method writeRecord() the value is no longer checked for null, so that in the default block the DBFException Unknown field type is thrown.
Is there a way to bypass or repair this? Â
DBFException: Unknown field type TIMESTAMP
here is the answer ) on this type I commented above
Unfortunately, I have no way to test with such a file. if it's not a secret, send it to my mail, this will give me the opportunity to test, not guess ) sumenkov.dv@gmail.com
I´ve send you a small version of our database. If there is a workaround to add a record without altering the field type of "ERFDATUM" we would be very happy.
I´ve send you a small version of our database.
Hello! I received the file, I will answer as soon as I can do the tests)
I´ve send you a small version of our database. If there is a workaround to add a record without altering the field type of "ERFDATUM" we would be very happy.
To my regret, without the author it is impossible to help. I have one solution, send it to the mail. But of course this is not what it should be.
Hi javadbf currently cannot write dbf7 files (that includes TIMESTAMP types and many others) There is a lot of work to do (new headers and register formats, null management, new data types) in writer and "sync mode" I'll work on it when I have the time. help is always welcome.
Hi, thanks for the reply. So we will search for a different solution.
Hi, I'm gettig this error:
java.lang.IllegalArgumentException: No support for writting TIMESTAMP at com.linuxense.javadbf.DBFField.setType(DBFField.java:431)
I guess it's not implemented yet, but is there an alternative to avoid it?