Repository navigation
sendDate ignores hour #40
Copy link
Copy link
Open
Description
Activity
Experienced the same. I guess the DateFormat is wrong in that case.
package com.createsend.util.jersey; /** * An extension of the Jersey JacksonJsonProvider used to set Jackson * serialisation/deserialisation properties */ public class JsonProvider extends JacksonJsonProvider { public static final DateFormat ApiDateFormat = new SimpleDateFormat("yyyy-MM-dd") { final SimpleDateFormat ApiDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final SimpleDateFormat ApiDateFormatTz = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); @Override public Date parse(String source, ParsePosition pos) { if (source.length() - pos.getIndex() == ApiDateFormat.toPattern().length()) return ApiDateFormat.parse(source, pos); return ApiDateFormatTz.parse(source, pos); } };For our project I rewrote com.createsend.Campaigns.send(...)
/** * Sends an existing draft campaign using the provided confirmation email and send date. * To schedule a campaign for immediate delivery use a <code>null</code> sendDate. * @param confirmationEmail An email address to send the delivery confirmation to. * @param sendDate The date to send the campaign at. This date should be in the clients timezone * @throws CreateSendException Thrown when the API responds with a HTTP Status >= 400 * @see <a href="http://www.campaignmonitor.com/api/campaigns/#sending_a_campaign" target="_blank"> * Sending a campaign</a> */ public void send(String confirmationEmail, Date sendDate) throws CreateSendException { Schedule sched = new Schedule(); sched.ConfirmationEmail = confirmationEmail; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); sched.SendDate = sendDate == null ? "Immediately" : dateFormat.format(sendDate); jerseyClient.post(String.class, sched, "campaigns", campaignID, "send.json"); }With that it sends the time with the date by starting the campaign. Would be nice if someone could change the SimpleDateFormat in the JsonProvider I showed in my last comment.
@niawahyuni Maybe you could add this.
And here is the pull request. #49
Metadata
Metadata
Assignees
Labels
No labels
When calling send on a Campaigns instance the provided Date sendDate parameter gets stripped of the time.
It will always fall back to 12:00 AM.