[wp-xmlrpc] Using date_created_gmt in a Java application??
Tom Hoag
tomhoag at gmail.com
Mon Sep 22 15:40:07 GMT 2008
I'm writing a Java app using the redstone xmlrpc library and having a
problem with both postCreated and date_created_gmt
Whenever I set the postCreated field, WP interprets/modifies the timezone to
GMT. For the time being, I've kludged the date (adding the difference
between the local TZ and GMT) so that WP gets the post date right. This is
ugly and I'd rather not do this . . .
It's been suggested that I use the date_created_gmt field, but I've had zero
luck getting this to work. It seems that WP cannot parse the passed in
java.util.Date as a valid date and subsequently defaults to the current
date.
Any thoughts on whats going on here? Anyone care to share some working
code?
thanks
tom
Here's a snipet of what I'm doing . . .
HashMap<String,Object> content = new HashMap<String,Object>();
java.util.Date postDate;
Calendar c = Calendar.getInstance();
c.add(Calendar.Days, 7);
postDate = c.getTime();
// snip . . .
// title, keywords, category, description, etc. are all populated . . .
//
content.put("title",title);
content.put("mt_keywords",keywords);
content.put("categories", new String[]{category});
content.put("post_status", "publish");
content.put("description", articlebody);
//content.put("date_created_gmt", postDate); // date doesn't get
interpretted correctly and defaults to the current date
content.put("dateCreated", postDate); // date is offset by local TZ - GMT
Object[] params = new Object[]{new String("n/a"), user, pass, content, new
Boolean("true")};
Object token;
try {
token = client.invoke("metaWeblog.newPost", params);
} catch (XmlRpcException ex) {
Logger.getLogger(WPDripFeederView.class.getName()).log(Level.SEVERE, null,
ex);
} catch (XmlRpcFault ex) {
Logger.getLogger(WPDripFeederView.class.getName()).log(Level.SEVERE, null,
ex);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://comox.textdrive.com/pipermail/wp-xmlrpc/attachments/20080922/99fef0a9/attachment.htm
More information about the wp-xmlrpc
mailing list