Search code examples
jsonspringmongodbspring-roo

How to add Timestamp to Spring-Data-Mongo in Roo?


I have a Spring Roo project I am trying to create based on log4mongo-java appender and I want to get access to the data entries that looks like:

{ 
"_id" : ObjectId("4f16cd30b138685057c8ebcb"), 
"timestamp" : ISODate("2012-01-18T13:46:24.704Z"), 
"level" : "INFO", "thread" : "catalina-exec-8180-3", 
"message" : "method execution[execution(TerminationComponent.terminateCall(..))]", 
"loggerName" : 
    { "fullyQualifiedClassName" : "component_logger", 
    "package" : ["component_logger"], 
    "className" : "component_logger" 
    }, 
"properties" : { 
    "cookieId" : "EDE44DC03EB65D91657885A34C80595E" 
}, 
"fileName" : "LoggingAspect.java", 
"method" : "logForComponent", 
"lineNumber" : "81", "class" : { 
    "fullyQualifiedClassName" : "com.comcast.ivr.core.aspects.LoggingAspect", 
    "package" : ["com", "comcast", "ivr", "core", "aspects", "LoggingAspect"], 
    "className" : "LoggingAspect" 
}, 
"host" : { 
    "process" : "2220@pacdcivrqaapp01", 
    "name" : "pacdcivrqaapp01", 
    "ip" : "24.40.31.85" 
}, 
"applicationName" : "D2", 
"eventType" : "Development" 
}

The timestamp looks like:

  "timestamp" : ISODate("2012-01-17T22:30:19.839Z")

How can I add a field in my Logging domain object to map this field?


Solution

  • That's just the JavaScript Date (according to the mongo docs, and as can be demonstrated in the shell), so try with java.util.Date.