-4

I want to convert Google DateTime into org.joda.time.DateTime.

This is the code of Google's implementation.

http://grepcode.com/file/repo1.maven.org/maven2/com.google.http-client/google-http-client/1.15.0-rc/com/google/api/client/util/DateTime.java

How I can implement this?

Stewart
  • 17,616
  • 8
  • 52
  • 80
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

2 Answers2

1

Returns the date/time value expressed as the number of milliseconds since the Unix epoch. If the time zone is specified, this value is normalized to UTC, so to format this date/time value, the time zone shift has to be applied.


public DateTime(long instant)

Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the default time zone.


// getValue() return millis since epoch
long millis = googleDate.getValue();

// Which is accepted by Joda DateTime's constructor
DateTime jodaDate = new DateTime(millis);
Stewart
  • 17,616
  • 8
  • 52
  • 80
0

Probably it is too late, but I have just solve a quite similar problem as follows

//Let's suppose date is our google DateTime
org.joda.time.DateTime jodaDate = date.getDateTime(date.getValue);

This creates a new joda DateTime from the google DateTimes' long value

Aldeguer
  • 821
  • 9
  • 32