Próbuję uzyskać bieżące milisekundy od początku tego dnia. Chciałbym dokonać następujących obliczeń. 86400000-currMilliSecondsFromBeginningOfDay
. Każda pomoc będzie bardzo ceniona. DziękiJodaTime Get Current Milliseconds From Beginning of Day
Odpowiedz
long result = new DateTime().millisOfDay().getMillis();
lub
long result = new DateTime().getMillis() - new DateTime().withMillisOfDay(0).getMillis();
lub
long result = new LocalTime().get(DateTimeFieldType.millisOfDay());
faktycznie getMillis() ma prywatny dostęp, możesz użyć DateTime(). GetMillisOfDay() zamiast –
@ moretti.fabio http://joda-time.sourceforge.net/apidocs/org/joda/time/base/BaseDateTime. html # getMillis(). To jest publiczne – Ilya
Masz rację, nie mam racji :) –
Można dostać początek dnia przy użyciu DateMidnight z biblioteki jodatime.
long todayStart = new DateMidnight().getMillis();
Podczas gdy DateTime constructor ustawi swoje pole millis na wartość bieżącą.
- 1. C# get string from textbox
- 2. JQuery - Get width: auto from inline style
- 3. MSBuild get reference reference from ProjectReference
- 4. Java Data do milliseconds
- 5. NSDateFormatter błąd milliseconds
- 6. scala: prevent companion Object from chiding definition of original Class
- 7. Odpowiednik JodaTime dla DateUtils.truncate()
- 8. Jak mogę sfałszować faktyczną datę JodaTime?
- 9. Czas konwertowania SQL na milliseconds
- 10. Jak mogę uzyskać nazwy dni tygodnia w JodaTime
- 11. mysql tuning variables - current & defaults
- 12. isc sql current timestamp function
- 13. Observable Current and Previous Value
- 14. Javascript: Uzyskaj aktualną stronę CURRENT źródło
- 15. Java 7: get Path of resource (jako obiekt typu Path)
- 16. JodaTime DateTime, ISO8601 GMT format daty
- 17. Zrozumienie JodaTime DateTime.parse (ciąg, formatowanie)
- 18. Java.util.Calendar - milliseconds od 1 stycznia 1970
- 19. Kopiowanie plików podczas pakowania - messages.properties z JodaTime
- 20. Uzyskiwanie delegata from methodinfo
- 21. Jak znaleźć Current Open Cursors w Oracle
- 22. ObjectiveC Parse Integer from String
- 23. Dlaczego funkcja Day() zwraca 30 w przypadku nieprawidłowych danych wejściowych?
- 24. ObservableCollection (Of T) vs BindingList (Of T)?
- 25. Przesłanianie BeanPropertyRowMapper do obsługi JodaTime DateTime
- 26. Wiosna @ResponseBody Jackson JsonSerializer z JodaTime
- 27. Zasoby biblioteczne z Robolectric 3 - JodaTime
- 28. JodaTime: Konwertuj lokalnie na UTC niejednoznaczność
- 29. SELECT MAX of COUNT
- 30. Perl hash slice from hash return from function
currentTimeMillis()% (24 * 60 * 60 * 1000) – Subin
@SubinS Po pierwsze dziękuję. Mam również problem z ustaleniem, gdzie mogę umieścić to w odniesieniu do mojej nowej zmiennej DateTime(). –
long diff = currentTimeMillis()% (24 * 60 * 60 * 1000); DateTime diffDate = new DateTime (diff); – Subin