Index: base/time/time.cc |
diff --git a/base/time/time.cc b/base/time/time.cc |
index ce25dea0589dfae7ad5b55ffd98a95a33fa7704a..a9e4b1cf90aa61c031feaa05f52a01111090f431 100644 |
--- a/base/time/time.cc |
+++ b/base/time/time.cc |
@@ -138,6 +138,19 @@ double Time::ToJsTime() const { |
kMicrosecondsPerMillisecond); |
} |
+int64 Time::ToJavaTime() const { |
+ if (is_null()) { |
+ // Preserve 0 so the invalid result doesn't depend on the platform. |
+ return 0; |
+ } |
+ if (is_max()) { |
+ // Preserve max without offset to prevent overflow. |
+ return std::numeric_limits<int64>::max(); |
+ } |
+ return ((us_ - kTimeTToMicrosecondsOffset) / |
+ kMicrosecondsPerMillisecond); |
+} |
+ |
// static |
Time Time::UnixEpoch() { |
Time time; |