简体   繁体   中英

JavaLite, get TIMESTAMP(6) WITH TIME ZONE

In my final study project, I am using Javalite/ActiveJDBC to get information in a DB. In my table Users , I have a colum with the type as TIMESTAMP(6) WITH TIME ZONE (example value 15-10-30 12:32:37.366954000 -04:00 ).

When I call the model for this table I cannot get the time. I also need to convert it to a string.

My model:

import org.javalite.activejdbc.Model;
import org.javalite.activejdbc.annotations.DbName;
import org.javalite.activejdbc.annotations.Table;

/**
 *
 * @author mrabia
 */
@DbName("myDB")
@Table("USERS")
public class Users extends Model{ }

In my webservice:

class getUserInfos () {
    .......
    Users.getTimestamp("CREATED_DATE");

    ...
}

Sorry, but your code is not correct. The getter methods on models are instance methods, not statics, so your code should not compile.

To answer your question, you could do this:

List<User> users  = Users.where("status = ? ", "active");
TimeStamp ts = users.getTimestamp("CREATED_DATE");

Additionally you need to add tags to your questions for people to get notifications. In this case two tags: 'activejdbc' and 'javalite'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM