Converting epoch time to a date
Anyone know of a function to do this. I cant find any in the api and my searches bring up nothing.
You can create your class that extends GregorianCalendar.Then you can access the protected class in super class. Following codes are what I write to handle this problem. Hope it help.
import java.util.*;
public class Test10{
public Test10(){
init();
public void init(){
MyCalendar calendar1 = new MyCalendar();
calendar1.set(2002, 07, 12);
System.out.println("time in epoch: " + calendar1.getTimeInMillis());
public static void main(String[] str)
new Test10();
private class MyCalendar extends GregorianCalendar
public MyCalendar(){
super();
public long getTimeInMillis()
return super.getTimeInMillis();
Similar Messages
-
How to convert epoch time to datetime in sql*loader Oracle
Hello,
I wan't to question how to convert epoch time to datetime in sql*loader Oracle. I try this script for convert epoch time to datetime in sql*loader, but error:
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
This is my loader:
LOAD DATA INFILE 'C:\Documents and Settings\Administrator\My Documents\XL_EXTRACT_211\load.csv'
into table TEMP_TEST_LANGY append
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
DATADATA CHAR "TO_DATE('01-JAN-1970','DD-MON-YYYY')+:datadata/86400"
This is my csv file:
79314313.7066667
79314336.2933333
79314214.3466667
This is my table:
CREATE TABLE TEMP_TEST_LANGY
DATADATA DATE
Thanks
Edited by: xoops on Sep 21, 2011 8:56 AM
Edited by: xoops on Sep 21, 2011 8:58 AMthanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
This is my error log:
Column Name Position Len Term Encl Datatype
DATADATA FIRST * , CHARACTER
SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Edited by: xoops on Sep 21, 2011 12:33 PM -
Converting EPOCH time stamp to time stamp in Oracle
Hi,
I need a help regarding how to convert the epoch Time stamp, to oracle date and time format.
for example,
for epoch time stamp:1204104116656
the time stamp should be :2008-02-13 12:43:00.351
Thanks in Advance
Basil AbrahamAre you sure you've got the right timestamp? Assuming this is a standard unix epoch time stamp with the epoch date starting at 1970-01-01 UTC the interval between 1970-01-01 UTC and 2008-02-13 is 13922 days, but your epoch timestamp divided by the number of miliseconds in a day 1204104116656/(1000*60*60*24) comes out to 13936.390... days a difference of 14 days 9 hours 21 minutes 56 seconds and 656 miliseconds.
Anyway to convert you need to convert your epoch date into an interval and add it to the starting epoch date (as a timestamp):
select to_timestamp_tz('1970-01-01 utc', 'yyyy-mm-dd tzr')+
numtodsinterval(1204104116656/1000,'second') dstamp
from dual;Message was edited by:
Sentinel -
How to convert epoch time stamp to timestamp.
Hi,
I need a help regarding how to convert the epoch Time stamp, to oracle date and time format.
for example,
for epoch time stamp:1204104116656
the time stamp should be :2008-02-13 12:43:00.351
Please help me on the sameSQL> select timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second') from dual;
TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
27-FEB-08 09.21.56.656000000 AM
SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('EST') from dual;
(TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
27-FEB-08 08.21.56.656000000 AM -05:00
SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('PST') from dual;
(TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
27-FEB-08 06.21.56.656000000 AM -07:00
SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('Europe/Berlin') from dual;
(TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
27-FEB-08 03.21.56.656000000 PM +02:00
SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('Canada/Mountain') from dual;
(TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
27-FEB-08 07.21.56.656000000 AM -06:00SY. -
How to convert Epoch time to Datetime (YYYYMMDDHH24MMSS)
Hi,
In our Oracle db, Datetime is stored as Epoch time (seconds since january 1st 1970). To get a readable date, I have converted those fields as followed:
TO_CHAR(TO_DATE('19700101000000', 'YYYYMMDDHH24MISS')+((DATE_FIELDS-18000) /(60*60*24)),'YYYYMMDDHH24MISS')
Result ex: 20100830135422
The problem is that the resulting fields are in VARCHAR2 instead of DATE so it causes issues in SAP BW reporting development. BW developpers can manage something to make it eventually work but I would like to correct this at the source if it is possible.
I have already tried to add another "TO_DATE" function at the beginning of the previous expression but I get a date in "DD-MMM-YY" format as a result even if I have forced another date format.
Any idea on how I could solve this?
Thanks a lot
PascaleOk, there is clearly a disconnect here.
Oracle stores dates in a DATE datatype. This means that, internally, it will store enough information for a 4 digit year, a month, date, hour in 24 hour time, minute, and second. All that information is stored in the DATE datatype inside the database, but, it's stored in an internal format, that has nothing to do with what it will look like when you print it. When you want to retrieve it, Oracle must have a date format string, so that it knows how to display that information. If you do not provide a date format string via the TO_CHAR() function, Oracle has a parameter called NLS_DATE_FORMAT that provides the default format to use. If you have not set the NLS_DATE_FORMAT, it defaults to DD-MON-YY.
So, having said all that, what are you actually trying to do?
You started with this expression:
TO_CHAR(TO_DATE('19700101000000', 'YYYYMMDDHH24MISS')+((DATE_FIELDS-18000) /(60*60*24)),'YYYYMMDDHH24MISS')How is that expression used? In a SELECT statement? Then you probably want it the way it's written above. In an INSERT statement? If so, then if the datatype of the column you're inserting into is DATE, then you probably need to eliminate that outer TO_CHAR conversion, so that the expression returns a date that can be inserted into DATE column.
Tell us more about what you want to do, and perhaps we can offer further help.
-Mark -
Convert millisecond time value to date
If i have a millisecond time value, say long timeValue, how do I convert this value to a time and a date?
Or directly set a new date using the constructor
Date(long date)
Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
N.B. - Note that the Date class method to set a date from a long is:
setTime(long time)
Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
setTimeInMillis() is a Calendar method , only. -
Convert utc time to oracle date
Hi ,
I want to compare two dates the date passed in will be say '0303090000000' with a dur_date I have in the table X .
dur_date is a DATE type ...
How can i do this in oracle?Hi,
Should I not use to_char(dur_date 'yyyy-mm-dd hh24:mi:ss') ?No, you should do it the other way around, convert passed string into DATE.
But what format is this string in?
'0303090000000'It seems to be one character too long, and it is unclear what it means. Depending of what meaning you put into it, it can be either one of these:
SQL> alter session set nls_date_format = 'dd-MON-rrrr'
Session altered.
SQL> select to_date('030309000000', 'ddmmyyhh24miss') date_ from dual
union all
select to_date('030309000000', 'ddmmrrhh24miss') from dual
union all
select to_date('030309000000', 'mmddyyhh24miss') from dual
union all
select to_date('030309000000', 'mmddrrhh24miss') from dual
union all
select to_date('030309000000', 'yyddmmhh24miss') from dual
union all
select to_date('030309000000', 'rrddmmhh24miss') from dual
DATE_
03-MAR-2009
03-MAR-2009
03-MAR-2009
03-MAR-2009
03-SEP-2003
03-SEP-2003
6 rows selected.But probably not 'yyyy-mm-dd hh24:mi:ss'
Regards
Peter -
How to convert epoch time to EST/EDT
10g sql
thanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
This is my error log:
Column Name Position Len Term Encl Datatype
DATADATA FIRST * , CHARACTER
SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Edited by: xoops on Sep 21, 2011 12:33 PM -
hi mates
can any one give me the java code to convert sql time to util date?
thanks in advanceSince java.sql.Time extends java.util.Date it is a
Date. Am i right here?How about looking it up? Then you'd know.
Yes, sql.Date extends util.Date.Sorry. I'm getting screen-tired. sql.Time extends util.Date, too. But they only show the time, no date. -
Convert Epoch Date Time to Date Time format
I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
Please note that i'm looking for datetime stamp, not just the date.
Thanks in advance!
Edited by: 830754 on Jan 27, 2011 11:18 AM
Edited by: 830754 on Jan 27, 2011 11:19 AMWorks for me. I see date and time (submitted 1000 for STARTTIME):
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
from dual
TO_CHAR(TO_DATE('01
01.01.1970 06:16:40Or do you mean something else? -
Does labview provide epoch time converter support?
Hi,
My product creates a data log file with time stamp. The time stamp is of the epoch format. The system is based on the linux. So I assume that this time stamp is a unix based format. How should I convert this time stamp data to the UTC format in labview?
Regards
GopalLabVIEW's time stamp is the number of seconds since 00:00:00 01/01/1904. Unix (and hence I presume Linux) time is the number of seconds since 00:00:00 01/01/1970, all times specified as GMT. So all you need to do to a Unix timestamp is to add the number of seconds between these two moments in time to obtain the LabVIEW timestamp.
You can generate this number by using Date/Time to seconds, giving the input as Day 1, Month 1, Year 1970, and all others zero. It gives 2082844800
Make sure that you treat the numbers as U32, as the current date/time exceeds the maximum value for as signed 32 but value.
Rod. -
Can I convert Facebook time Text to Project Siena's Date value ?
Can I convert Facebook time Text to Project Siena's Date value ?
I want to show create_time on screen by my Localtime formatted text.
Facebook time Text = 2014-07-14T11:22+0000
I want to show = 2014/07/14 18:22
My Time Zone is +09:00, Osaka/Japan.
Currently I try it by Text/Replace/Replace/Replace/Left/DateValue/+ , etc.
And I ask more simple way.
Regards,
Yoshihiro KawabataThank you Andy , and Robin, I can.
Text(TimeValue(Substitute(ThisItem!created_time,"+0000",".000Z")),"yyyy/mm/dd hh:mm")
At Facebook Albums's Gallary, I can convert from Facebook created_time to Localtime Text DateTime.
and I hope more easy way like Excel Power Query's one.
Regards,
Yoshihiro Kawabata -
Can I convert Twitter time Text to Project Siena's Date Value ?
Can I convert Twitter time Text to Project Siena's Date Value ?
I want to show localtime of Twitter created_at.
Twitter time text = ThisItem!created_at , ex: Tue Jul 15 17:19:00 +0000 2014
I want to show 2014/07/16 02:19 by Japan localtime.
Regards,
Yoshihiro KawabataSiena uses JavaScript to parse date/times, via the TimeValue function. A good specification regarding what is acceptable can be found here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse
The example above is truly bizarre: I thought I had seen it all. You will need to turn that form into one of those listed on the above site, using string functions to chop it up and reassemble it into a saner form. -
Converting a date time to a date only
Post Author: Dockman
CA Forum: Formula
I am working on a report that has a running total field. The running total field keeps a running total and resets every time that a date changes. the problem is that my dates include times, therefore the running total resets on every line. How can I convert my date (in date time format) to be only a date so that it does not reset on every line?
Obviously, I am not a programmer so I apologize if this is a stupid question.Post Author: yangster
CA Forum: Formula
if you are doing it inside crystal you can use the date functiondate({your.datetimefield})if you are doing it at the db level in a command this will vary depending on your db -
Convert Epoch (UNIX) time to a readable timestamp
Post Author: uberwolfe
CA Forum: Formula
I am pulling data from a MS SQL 2000 database (for you phone phreaks out there, I am going against the Cisco CallManager CDR database). The datetime stamp is in there as UNIX time. I need to convert and split this into two fields, a date field and a time field. As I have inherited this and don't know a lot about Crystal Reports I am at a loss. Currently the report I have (that a developer who is no longer with us wrote) has two formula's. The formulas are as follows: Time:CTime ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) Date:CDate ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) When the time is returned, it looks to be in GMT. What type of formula would I need to have to convert the time to the correct time within the timezone I am in. Any help would be appreciated.Post Author: uberwolfe
CA Forum: Formula
Gave me an error stating the year needed to be between 1 and 9999. I modified it as such CTime (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569)
CDate (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569) Running it right now, but it takes a while. Let's see what happens. Will post in a bit.
Maybe you are looking for
-
Reg. A/R Credit Memo
Hi all, Can anyone tell me how to address the Excisable Items Returned from Customer. Let me tell u first what are all i tried in SAP B1. I am Using SAP B1 2005B version of Patch level 39. Here i have saled an item which is excise goods to customer t
-
In Dreamweaver CS5 - Spry elements visable in LiveView Only
Web page: www.muohio.edu/youth In Dreamweaver the Spry Tabbed Panels and Collapsible panels work fine as published, and in LiveView. However in Design View the tabbed panels only show the top content, the styling is not applied. The collapsible pane
-
Bear with me, I've not done this before. I can't seem to reliably print an envelope when using Pages. I go to "file" click "print", click "ok", see the printer icon flash in the dock with a red "1" (indicating a printing job), but then the icon dis
-
hello everyone we'd like to upload a podcast on itunes. we have an mp3-file and within the upload process itunes is asking for a "url" and we have no idea which information we have to put in here ... :/ i suppose that we have to upload the mp3-file f
-
How do u find out the full stepping build of a cpu
using everest i get CPU Stepping A2 CPUID Revision 000006A0h sandra gives me generation G7,revision stepping A/0(0) stepping mask A2 CPU-Z stepping 0 i would like to know how to find out the full stepping build inthe format eg. dkv4d Aqea 0324