Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#SimpleDateFormat.getDateTimeInstance()' - 2 code snippet(s) found

 Sample 1. Code Sample / Example / Snippet of com.google.gson.JsonObject

	public JsonElement serialize(Event e, Type typeOfSrc, JsonSerializationContext context) {

DateFormat format = SimpleDateFormat.getDateTimeInstance();

JsonObject event = new JsonObject();

event.addProperty("logId", e.getStoreID());

event.addProperty("id", e.getID());

event.addProperty("time", format.format(new Date(e.getTime())));

event.addProperty("type", toAuditEventType(e.getType()));

JsonObject eventProperties = new JsonObject();

Map<String, String> p = e.getProperties();

for (String key : p.keySet()) {

eventProperties.addProperty(key, p.get(key));

}

event.add("properties", eventProperties);

return event;

}


   Like      Feedback      com.google.gson.JsonObject


 Sample 2. Populate DateFormat using SimpleDateFormat

public JsonElement serialize(Event e, Type typeOfSrc, JsonSerializationContext context) {
DateFormat format = SimpleDateFormat.getDateTimeInstance();
JsonObject event = new JsonObject();
event.addProperty("time", format.format(new Date(e.getTime())));
return event;
}

   Like      Feedback      java.text.DateFormat  SimpleDateFormat.getDateTimeInstance()  SimpleDateFormat



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus