Questions tagged [localtime]

Calendar time expressed relative to the user's local timezone.

Calendar time expressed relative to the user's local timezone.

461 questions
3
votes
1 answer

UTC time wrong in SQLite

My Centos 7.6 server is physically located in Germany but is configured so that it presents me (in London) with the correct local time and UTC time. $ date Tue Jul 16 08:31:51 BST 2019 $ date -u Tue Jul 16 07:31:55 UTC 2019 But inside an SQLite…
Dave Cross
  • 68,119
  • 3
  • 51
  • 97
3
votes
2 answers

Convert UTC java.sql.Time to java.time.localtime with correct DST

I have a problem to convert a java.sql.Time (UTC) which is fetched from a database to a java.time.LocalTime (GMT+1 DST). It is always missing the DST hour. So like a Time of 03:00 is only converted to a LocalTime of 04:00 instead of 05:00. //Saved…
3
votes
1 answer

localtime(_r) inversed behavior

I wrote small program to show local time relative to GMT (or UTC): struct tm l; time_t stamp = 1534435540; // No TZ set printf("TZ=%s\n",getenv("TZ")); gmtime_r(&stamp, &l); printf("UTC: %0u:%0u:%0u -…
x_arrange
  • 317
  • 2
  • 12
3
votes
2 answers

generate random LocalTime in a specific range

I have two LocalTime objects: LocalTime time1 = LocalTime.of(8, 0, 0); LocalTime time2 = LocalTime.of(15, 0, 0); and I want to generate a random LocalTime object between these two objects. I already tried to do it with rand.nexInt() Random rand =…
Marco
  • 120
  • 1
  • 12
3
votes
5 answers

Average of two LocalTimes

How do I get the average of two LocalTimes? Can't find any suitable methods for this. So for example 08:00 and 14:30, should return (14-8)/2 = 3 + minutes (30-00= 30)/2, so 3:15 And then smth like Localtime xxx = LocalTime.parse("08:00",…
Not Dutch
  • 49
  • 7
3
votes
3 answers

Get LocalTime from difference between two LocalTime's

I'm having issues finding an elegant way to subtract one LocalTime from another, but not by some amount of seconds, or minutes, but just this: LocalTime difference = now - before; Obviously this won't work, so in reality, what I'm after, is…
user5549921
3
votes
1 answer

Parse (ss.nnn) second and nanosecond in Java 8

I am trying to parse second and nanosecond, i.e., 10.337000, where 10 is second and 337000 is nanoseconds in Java 8. I am not able to figure out how should I parse these values into LocalTime. I have tried DateTimeFormatter.ofPattern("ss:nnnnnn"),…
Nitishkumar Singh
  • 1,781
  • 1
  • 15
  • 33
3
votes
1 answer

SQL DateTimes stored in UTC get beginning of day based on offset

This may be the most pathetic question ever asked related to SQL and date/time values, but I could use some help... Trying to setup a function/job that will run at a specified time or times in eastern, mountain, central, and pacific time zones (in…
RSolberg
  • 26,821
  • 23
  • 116
  • 160
3
votes
6 answers

How to convert String containing date and time to LocalTime variable

I was converting a sequence of Strings which contained three different times Start, end and duration "00:01:00,00:02:00,00:01:00" to LocalTime variables: for (final String str : downtime) { final DependencyDownTime depDownTime = new…
DevRight
  • 345
  • 1
  • 6
  • 25
3
votes
1 answer

IAR , localtime, mktime

I am using the DLib for your IAR-Compiler and wanted to convert a UTC-timestamp to a local timestamp. I am located in Germany hence my implementation for the __getzone-method is as followed: char const * __getzone() { return…
3
votes
4 answers

How to avoid negative time between time difference?

I'm developing an app in which I'm using Java8 Time. I'm facing an issue. Let's say Time A is 08:00 and Time B is 17:00, so the difference of between these two times will be 9h which in my case is correct, but if Time A is 18:00 and Time B is 02:00…
Junaid
  • 664
  • 5
  • 18
  • 35
3
votes
1 answer

Convert serialized HTML time field to java.time.LocalTime

I have created a Spring Boot Controller that takes an Event form object. @RestController @RequestMapping("/Event") public class EventController { @RequestMapping(value = "/create", method = RequestMethod.POST) private…
tcelvis
  • 155
  • 2
  • 14
3
votes
3 answers

What is the difference between the current timestamp in the GMT time zone and the current timestamp in your local time zone?

This is a sample question i found at ZEND php certificate practice test, the correct answer of this question is: " There is no difference between the current time in any time zone—the current time is an absolute point in time! " This answer is very…
3
votes
1 answer

How to avoid time_t variable?

Newbie pointer/address optimization question. As an exercise, I wrote this code. /* ------------------------------------------------------------- FUNC : dateplusdays (date plus days) add/substract days to/from date days can be…
geohei
  • 696
  • 4
  • 15
3
votes
1 answer

C++ std::localtime daylight saving time rule (dst) european vs american

I've problem with use of the std::localtime function. When I transform a std::time_t to a local struct tm, it always use the american daylight saving time whereas I want to use the european one (France). UTC : 03/19/16 16:56 is transformed in Local…