I am using google data api which gives date in datetime format. I want to convert this DateTime format date in Gregorian calendar date format. Does anyone know any methods for doing this?
*Edited the question
I am using google data api which gives date in datetime format. I want to convert this DateTime format date in Gregorian calendar date format. Does anyone know any methods for doing this?
*Edited the question
That class is definitely not Google's best work (I link to the API so I can confirm we are talking about the same class and version). Here is what I would do:
public class DateTimeConverter extends DateTime {
private DateTime originalTime;
public DateTimeConverter(DateTime originalTime) {
this.originalTime = originalTime;
}
public java.util.Date getDate() {
return new java.util.Date(this.value);
}
}
Sample usage:
DateTime originalTime;
//Populate variable and then:
java.util.Date myDate = new DateTimeConverter(originalTime).getDate();
From there you can make a Calendar. Dealing with what to do if the DateTime represents a Date only, and timezone issues, you can deal with from there (I don't know your requirements) but if you have to get serious about it, use JodaTime to handle this as much as possible.