All Questions
Tagged with java unix-timestamp
121
questions
-2
votes
2answers
67 views
How to convert time in utc second and timezone offset in second to date using java-8?
I have a date in utc second and its time zone offset in sec. I would like to convert it to date string in format yyyy-mm-dd using java8 ZoneOffset class. Below is the time in seconds and offset
long ...
0
votes
2answers
84 views
java.time: Compare two Instants - get the number of hours, minutes, seconds, years, months between the two [duplicate]
I tried this code:
public class TimePassed {
private long seconds;
private long minutes;
private long hours;
private long days;
private long years;
...
public TimePassed(...
0
votes
1answer
75 views
Sunrise and sunset time are equal after converting
I am trying to convert the millisecond format of time provided by openweathermap but when I convert them the times are just 1minute apart.
I have tried converting using Simpledateformat.
fun ...
3
votes
1answer
56 views
Fastest way to get nanos unix epoch time in Java
I currently do this to successfully get the current epoch time in nanos:
Instant inst = Instant.now();
long time = inst.getEpochSecond();
time *= 1000000000l;
time += inst.getNano();
However, it's a ...
-2
votes
1answer
129 views
Why is Android System.currentTimeMillis() not an accurate Timestamp? [duplicate]
I've encountered what appears to be a very unusual bug while developing an android application.
The following code in my MainActivity onCreate method:
long ts = System.currentTimeMillis();
System....
0
votes
0answers
53 views
Convert unix time to Date in JFreechart?
Using the JFreechart library:
I have a two dimensional double array and I want to display all timestamps (unix time) as a Date format (like dd/MM/yyyy). I can generate the chart but it shows the X-...
0
votes
2answers
69 views
Calendar.setTimeInMillis error - why is that? [duplicate]
calendar gets wrong unix time as I got.
long millis = 1568814839L;
System.out.println(millis); //1568814839
Calendar.getInstance(TimeZone.getTimeZone("Asia/Tashkent"));
calendar.setTimeInMillis(...
0
votes
2answers
60 views
get previous hour/previous day timestamp from a unix value
i have an epoch timestamp of 1567318967 (September 1, 2019 6:22:47 AM). From the given epoch timestamp, How do I get the previous hour and previous day and output the result in epoch using Java?
I.e. ...
0
votes
4answers
54 views
Unix time/ epoch time: Date representation or time block?
I've recently taken over some responsibility of a database, and one of the fields is "time worked". This is represented as a VARCHAR in MySQL and is in the form:
'1970-01-01 00:05:46' (example)
All ...
0
votes
2answers
299 views
How get accurate UTC timestamp in android
I do not know which one is right for get UTC time
My code is
System.currentTimeMillis()
for java android
Is the result correct for international?
Maybe user can change device time and result be ...
-1
votes
1answer
78 views
Issue: Set Alarm Based on UnixTimestamp
I am trying to set the alarm based on UnixTimestamp, but always the application send alarm before the time i set it , e.g i set alarm on 1563551362 , now the problem is i received the alarm not on ...
1
vote
4answers
65 views
Why does a date conversion return different timestamps?
I am converting a GregorianCalendar instance to a Date to get a unix timestamp.
But I was wondering why the same date returns different Unix timestamps each time.
SimpleDateFormat sdf = new ...
1
vote
1answer
36 views
Hive UDF with date incrementing
I am attempting to write a user defined function that will allow you to input a date(current_date) and a range and the query will return the following dates along with how many dates have passed. As ...
1
vote
2answers
87 views
How to parse different date strings to LocalDate/Year?
I get list of objects from Json, each of them includes date String. There are two different formats, one is standard "yyyy-MM-dd" format, second is just year "yyyy". What is the elegant way to parse ...
1
vote
3answers
107 views
Java Timestamp with Fractional Seconds
How can I print Java Instant as a timestamp with fractional seconds like 1558766955.037 ? The precision needed is to 1/1000, as the example shows.
I tried (double) timestamp.getEpochSecond() + (...
-1
votes
3answers
870 views
Java Converting 19-digit Unix Timestamp to a Readable Date
I am trying to convert 19 digit Unix timestamp such as 1558439504711000000 (one and a half quintillion) into a readable date/time format. My timestamp ends with 6 zeros which suggests the time is in ...
-1
votes
1answer
97 views
Unix Time For China
I am trying to get the local time of China. I get the unixTimeStamp from the worldtimeapi.org website.
Problem: I get my local time instead of China time.
private class BackgroundProcess extends ...
0
votes
1answer
973 views
String (Date and Time) to Unix Timestamp in Java [duplicate]
I am pulling data from an API, and one of the pieces of data I get is a date and time. The date and time is returned in a string format and I need to get that in to a Unix Timestamp for my mySQL ...
1
vote
2answers
74 views
Java - convert unix time in miliseconds with time zone to timestamp
I have a string for example:
1517439600000+0100
and I want to convert it to unix time in miliseconds with no timezone.
how can I do it?
p.s.
1) I cant use substring(0,5) and add 3.6m miliseconds to ...
0
votes
0answers
42 views
How can I convert an already formated time back to unix in Java? [duplicate]
I am extracting time from a web page which is formatted like so -> Sep 30, 2018 at 4:00 PM
Now my question is, how do I convert the string to UNIX timestamp so that I can work on it?
3
votes
1answer
104 views
What does it mean to % 2147483647L on epoch time?
I just stepped onto problem with generating id for notification in Android.
I'm going through some notification-handling-sdk and they are using this code to generate notification id:
private int ...
0
votes
0answers
31 views
Difference in Server UNIX time and device current time
I get Unix timestamp from server, it can be some order creation time:
1531740385
I need to show some data, 20 minutes after this time from server.
I tried this approach:
currentUnixTime = (int) (...
-2
votes
2answers
832 views
Format using SimpleDateFormat to get a Unix-Timestamp [closed]
What format must the SimpleDateFormat have to format from unix timestamps to unix timestamps?
Having this code:
String format = System.getProperty("myformat");
SimpleDateFormat sdf = new ...
0
votes
2answers
842 views
Java: Unix time in seconds to milliseconds
I get a 10 digit timestamp from a json file and I've just figured out that this is Unix time in seconds and not in milliseconds.
So I went to my DateUtils class multiplied the timestamp in seconds ...
3
votes
2answers
3k views
Converting unix timestamp to datetime in Java
I have an Unix timestamp (with microsecond precision) value in 1.514408397505346E9. What is the correct way to convert it to readable date time format?
Is it correct to convert like below?
java.util....
1
vote
1answer
523 views
Name of a standard for time representation in milliseconds
I'm looking for the name of the standard for time, represented in milliseconds since midnight January 1, 1970 UTC. We can get one calling System.currentTimeMillis() in Java. For example when we are ...
0
votes
0answers
42 views
Unix time to normal time [duplicate]
I am making a project about quake report with json parsing. I am getting the info on https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_day.geojson but in this site time is unix time, so ...
0
votes
0answers
349 views
Why SQLite stores dates in 13-digits format? And why can't IDE read this format properly? Java
In SQLite I use integer to store dates. When I save any date (which I do by converting LocalDate to java.sql.Date) it shows as 13-digit integer.
just like this
According to sqlite docs dates should ...
-2
votes
2answers
65 views
How to convert time from google places API in JAVA
I have a question. I've never did that before. So how I can to convert time in format, what Google Places Api is giving me, and to get hour of day from that?
-5
votes
1answer
91 views
Getting time of special timezone in UNIX-time format. Android [duplicate]
I need to get current time in UNIX format. But with System.currentTimeMillis() i get time, which is not time of my timezone. (My timezone is "GMT+3")
I want to convert my local time to UNIX format. ...
-2
votes
1answer
886 views
Convert LocalTime for given zone to unix epoch seconds without the date component in java
We received time as hour =11, minutes=29,seconds=54,milliseonds=999 along with timezone information.
How to convert this time to unix epoch milliseconds with no date part.
I have tried this code :
...
1
vote
1answer
2k views
Converting UnixTimestamp to TIMEUUID for Cassandra
I'm learning all about Apache Cassandra 3.x.x and I'm trying to develop some stuff to play around. The problem is that I want to store data into a Cassandra table which contains these columns:
id (...
2
votes
1answer
3k views
Spring boot @RequestParam unix timestamp to LocalDateTime [duplicate]
Let's say I have in my RestController
@GetMapping("/")
public list(@RequestParam LocalDateTime date) {
}
and I make a GET request with date request param as unix timestamp like this:
http://...
0
votes
3answers
3k views
Java get current day from unix timestamp [duplicate]
I want to convert unix timestamp to only the current day, like the current day of the month of current day of the year, is it possible to do only using math, like *, /, or something?
0
votes
1answer
146 views
UNIX Timestamp to Datetime inconsistencies with MS SQL
I currently develop for BigSense and we support three database backends: MySQL, Postgres and MS SQL. Recently I ran into an interesting times/query issue when writing test cases.
Given the following ...
-1
votes
5answers
2k views
Check if timestamp older than 30 seconds
I am trying to determine if a timestamp is older than 30 seconds, but for some reason it is coming back as older than 30 seconds when it hasn't even been a couple seconds.
Example: https://ideone....
1
vote
2answers
778 views
Unexplained zero added when going from java.util.Date to java.sql.Timestamp
Consider the following test code (Try it here yourself on ideone.com - an online Java compiler):
class Main {
public static void main (String[] args) throws Exception {
Main m = new Main()...
1
vote
1answer
321 views
Storing unix timestamp in sql
I have a unix date in long format
Long tmpLong = (Long) local.getValue();
Here is the value of tmpLong
1485710457166
Now I want to store this variable inside of my SQLite DB, after some ...
0
votes
1answer
1k views
How to convert current UTC time into Linux Timestamp [duplicate]
I am trying to get current android device time, and convert it into UTC timezone, then i need to convert it into Unix Timestamp.
I google it, found some solutions, tried few, but nothing helping me ...
0
votes
1answer
379 views
Convert time in IDT/IST to unixtime in UTC [duplicate]
I am trying to parse IDT and IST dates to unixtime in UTC
For example:
Thu Sep 10 07:30:20 IDT 2016
For this date I would want to get unix time for the date but in hour of 04:30:20
And if it was IST ...
1
vote
2answers
683 views
Current time as 32bit UNIX timestamp and time offset
I working with android BLE.
Need to write to characteristic Current time as 32bit UNIX timestamp. After that write Current timezone offset from UTC in seconds. Probably problem is in coverting to 32 ...
0
votes
3answers
637 views
How is local time calculated from Unix timestamp
If unix timestamp is the same across the world how is am I able to get local time.
Or is it based on the different timezones the timestamp is different. i.e. I am in US the current seconds from UTC ...
-1
votes
1answer
100 views
Unix timestamp conversion accuracy for big numbers on Android
I'm testing the following value from the list on this site:
Regular date: 500, January 1 = Unix Timestamp: -46388678400
However, running the following Java code on Android:
GregorianCalendar ...
1
vote
2answers
698 views
Bug retrieving current time on Android with a given timezone
In my application I retrieve from a webservice an unix timestamp (between 0 and 15minutes in the future) and I display a countdown to that time in the form of XXm-XXs.
So I simply do System....
0
votes
2answers
39 views
Get Unix time from TextView
I have TextView with time: HH:mm:ss:ms
For example I have time: 00:20:03:19. My function returns -9596
How to convert this time to unix time? where is the mistake? Thanks.
private long ...
0
votes
3answers
124 views
how to convert timestamp format to date-format in Java?
How to convert timestamp 1470989229.000014 to date format mm-dd-yyyy in java?
I could do it for different timestamp formats but I could not parse this one.
The database used is MySQL so the timestamp ...
-4
votes
1answer
62 views
Why does setting the minutes, hours and seconds to the same as a unix timestamp in Calendar give the wrong time?
I have a timestamp: 1454716800 which is a representation of 02/06/2016 @ 12:00am (UTC). You can see it's 0 hours (on a 24 hour clock), 0 min, 0 seconds. But when I create it as a Calendar object and ...
0
votes
1answer
163 views
Java: round unix time (Long) to first day of the month
I'm trying to round a unix time to the first day of the month in Java, but without success. Example:
1314057600 (Tue, 23 Aug 2011 00:00:00 GMT)
to
1312156800 (Mon, 01 Aug 2011 00:00:00 GMT)
...
2
votes
1answer
1k views
Android ScanResult Timestamp Field - How accurate is it?
I've been using wifiManager.startScan(); to receive the data from nearby Wi-Fi access points. This is returned as a List of ScanResult. This class can be found here:
http://developer.android.com/...
-1
votes
1answer
101 views
Use UNIXTIMESTAMP with ummalqura-calendar Library [closed]
I am using ummalqura-calendar to Show Hijri Date in my Android Application
am getting date from back end Service as UNIXTIMESTAMP, How can i use this format with the library