DateConversion with DateFormat to Timestamp
Hello,
I want to convert a string that has the format "dd. MMM yyyy" to a timestamp (what you get, wenn you call "getTime()" on a Date.
I tried this:
var oDateFormatter = sap.ui.core.format.DateFormat.getDateInstance({
source: {
pattern: "dd. MMM yyyy"
pattern: "timestamp",
}, "de");
console.log("date", oDateFormatter.format("21. Sep 2014"))
But it gave me an error:
Uncaught TypeError: undefined is not a function LocaleData.js:6
When I remove the ,"de" I get this Error:
Uncaught TypeError: undefined is not a function DateFormat.js:16
Can someone help me?
I need to use parse instead of format.
Similar Messages
-
Open a url and view the files with it's timestamp
Hi guys,
I need to create a flow service in SAP BC to connect to a server by it's url and display it's files with it's timestamps.
I have never done this b4, and usinf SAP BC makes it harder for me.. Mostly I need to know how to access the server and view the files with their timestamp.
Any guidance for me will be much appreciated.
Thank u.Yes,
It's like this. I will connect to an FTP server. Then I need to view the files it the server or folder i specify with their respective timestamps.
I am using SAP BC and it's webMethods to create the JAVA flow service. I am only now familiarising myself with SAP BC.
Moreover I have never done a coding to access a server and list it's file. I can do it o view in a local directory using JFrame aand stuff... But SAP BC doesn't support those..
So If u can give me some guidelines to follow.. i would appreciate it.
Here's what i have come up with so far
public static final void ReadFileServer( IData pipeline ) throws ServiceException
//define input variables
IDataCursor idcPipeline = pipeline.getCursor();
String path = null;
path = (String)idcPipeline.getValue();
// Check if url is in the pipeline
if (idcPipeline.first("path"))
File dir = new File(path);
String filesFound[]=dir.list();
long [] age;
age = new long[filesFound.length];
for (int i = 0; i < filesFound.length; i++)
age = new File(filesFound).lastModified();
String temp = "";
for (int i = 0; i < age.length - 1; i++)
for(int k = i+1; k < age.length ; k++)
if (age > age [k])
temp = filesFound;
filesFound = filesFound[k];
filesFound[k] = temp;
for (int i = 0; i < filesFound.length; i++)
//get url out of the pipeline
path = (String)idcPipeline.getValue();
//insert the FILES into the pipeline
idcPipeline.insertAfter("filesFound", filesFound);
idcPipeline.insertAfter("age", age);
//If it is not in the pipeline ERROR
else
age = "False";
idcPipeline.insertAfter("path", path);
//insert the successFlag into the pipeline
idcPipeline.insertAfter("age", age);
//Always destroy cursors that you created
idcPipeline.destroy();
return;
} -
Problem with subqueries returning TIMESTAMP's
I've got problems with some subqueries returning TIMESTAMP values.
I've build a case for easy reproduction, with this query:
SELECT iil.iil_lot_num ,
(SELECT max ( lot_data_validade )
FROM lot
WHERE lot.lot_mat_cod = iil.iil_mat_cod AND
lot.lot_num = iil.iil_lot_num ) as validade
FROM iil
WHERE ( iil.iil_inv_serie = 109 ) and
( iil. iil_inv_num = 16 ) and
( iil.iil_mat_cod = 111 )
When I run it, it gives the error:
General error;-9999 POS(1) System error: invalid_indexorder
knldiag also gives:
2009-07-28 15:03:18 9943 ERR 51080 SYSERROR -9999 invalid_indexorder
I'm running on 7.6.06.03.
Previous versions were giving another message:
SQLCODE: -9999 System error: Otherwise unknown errorcode
If I change max ( lot_data_validade ) to max ( year (lot_data_validade) ), it works. The problem is specifically with fetching that timestamp value from the subquery.
Backup for reproduction of the problem is on:
http://www.tecnova.com.br/maxdb/backup_problem
(i've isolated only the tables involved in the problem, so the backup is tiny -> 4.3MB)HI Elke,
I had the same idea at first but was largely disappointed to find that this 'corrupt index' is indeed a temp. resultset:
--> max() query
OWNER TABLENAME COLUMN_OR_INDEX STRATEGY PAGECOUNT
DBA IIL RANGE CONDITION FOR KEY 61
IIL_INV_SERIE (USED KEY COLUMN)
IIL_INV_NUM (USED KEY COLUMN)
IIL_MAT_COD (USED KEY COLUMN)
INTERNAL TEMPORARY RESULT EQUAL CONDITION FOR KEY 1
IIL_INV_SERIE (USED KEY COLUMN)
DBA LOT NO STRATEGY NOW (ONLY AT EXECUTION TIME)
INTERNAL TEMPORARY RESULT TABLE SCAN 1
RESULT IS COPIED , COSTVALUE IS > 2 E10
The cost expectation is really awesome here...
--> max(year()) query
OWNER TABLENAME COLUMN_OR_INDEX STRATEGY PAGECOUNT
DBA IIL RANGE CONDITION FOR KEY 61
IIL_INV_SERIE (USED KEY COLUMN)
IIL_INV_NUM (USED KEY COLUMN)
IIL_MAT_COD (USED KEY COLUMN)
INTERNAL TEMPORARY RESULT EQUAL CONDITION FOR KEY 1
IIL_INV_SERIE (USED KEY COLUMN)
DBA LOT NO STRATEGY NOW (ONLY AT EXECUTION TIME)
RESULT IS COPIED , COSTVALUE IS
This time the optimizer ran out of words for the expected effort for this query execution...
The problem really seems to be the subquery-select as we can strip down the example to
select (select max(lot_data_validade) maxval
from lot
where lot.lot_mat_cod=111) as maxval
from dual
and still see the error...
regards,
Lars -
All,
I am using a DateFormat to format TimeStamps to useful strings. I am getting some rather unexpected results in the form of extra leading zeros.
For example,
1) 03/07/2002 14:0043:51PM
2) 03/07/2002 0014:43:51PM
3) 0003/07/2002 14:0043:51PM
4) 03/0007/2002 14:43:51PM
Any ideas?
-jonathanI have seen reports about the DateFormat class giving erroneous results when it's used to create TimeStamps for log files, this could be a bug -- you might want to check the bug database to see if it's been fixed and at what revision number when it was fixed. In the meantime, you might want to format the date yourself with something like this (it might even be faster)
import java.util.*;
class DateFormat {
static Calendar c=Calendar.getInstance(TimeZone.getDefault(),Locale.getDefault());
public static String Now () {
c.setTime(new Date(System.currentTimeMillis()));
int hour=c.get(Calendar.HOUR_OF_DAY);
String AMPM=" AM";
if (hour>11) AMPM=" PM";
return i2s(c.get(Calendar.MONTH),2) + "/"+
i2s(c.get(Calendar.DATE),2) + "/"+
i2s(c.get(Calendar.YEAR),4) + " "+
i2s(hour,2) + ":"+
i2s(c.get(Calendar.MINUTE),2) + ":"+
i2s(c.get(Calendar.SECOND),2)+AMPM;
private static String i2s(int in, int len) {
String tmp=""+in;
if (tmp.length()>len) return tmp.substring(tmp.length()-len);
while (tmp.length()<len) tmp="0"+tmp;
return tmp;
public static void main(String[] args) {
System.out.println(Now());
}V.V. -
Problem with selecting from timestamp field for a particular date
We're running 10g and we have a timestamp field whose values look like this:
SQL> select timeinserted from files where rownum < 3;
TIMEINSERTED
16-APR-05 01.08.35.97634 PM
16-APR-05 01.16.10.00419 PM
SQL>
I'm trying to run this query, but it returns no rows even though I know there should be some:
select timeinserted from files where timeinserted = '27-MAY-05';
I know I just need to somehow tell it to convert the timestamp to date or something like that. How should I rewrite this query? Thanks...select timeinserted from files where timeinserted = '27-MAY-05';
this is poor coding, you compare a date with a varchar2. Not to mention using 2 digits years...
try something like
select timeinserted from files where timeinserted >= to_timestamp('27-MAY-2005', 'DD-MON-YYYY') and timeinserted<to_timestamp('28-MAY-2005', 'DD-MON-YYYY'); -
ie. Is this valid?
<query>
<description>Find data between dates</description>
<query-method>
<method-name>findMetricsByDate</method-name>
<method-params>
<method-param>java.sql.Timestamp</method-param>
</method-params>
<method-params>
<method-param>java.sql.Timestamp</method-param>
</method-params>
</query-method>
<result-type-mapping>Local</result-type-mapping>
<ejb-ql>
SELECT OBJECT (o) FROM MetricResults AS o WHERE MetricResults.date > ?1 AND MetricResults.date < ?2
</ejb-ql>
</query>No. Not with current EJB 2.0 CMP specs at least. Later revisions are supposed to fix this, but for now, this seriously limits the usefulness of EJB-QL.
.P. -
Open a file starting with and latest timestamp
hi all,
i need to open a file whose name starts with ABC_DELTA and has the latest timestamp. i mean there are many files in this folder and some files will start with ABC_DELTA, but i need to pick up the file which has the latest timestamp or is the newest. how would i implement this. pls help.
thanks.ag2011 wrote:
the files creation time. the file wont be modified. its like a log. and i need to parse it. thanks.Well, you're SOL if you want to use creation time: check out the File API. But you should be able to use lastModified in its place. -
Two records getting inserted with the same timestamp...
hi all,
I am trying to submit a form . Now whenever I click submit before I insert any
data sent in that form I make a check (SELECT stmt. to see if that record can
be inserted ...few business validations..) and if the check is successful I then
proceed for the necessary insert into a table the Primary key for which is a running
Oracle sequence.
But if I click on the Submit button twice in close succession I have observed
may be 1 in 1000 attempts I am able to submit two records with the same time stamp
for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I don't
think ORACLE's date precision is beyond seconds.
So any suggestion ..what is the best way to handle such things : one can be
to place the same business validation check just before the ending brace of the
method , or secondly sucmit the form thru javascript and don't submit it twice
even if the user clicks the submit button twice... any suggestion which u can
give .. are welcome.
thnx in advance
sajan
Is the pkey a timestamp or an Oracle sequence? The latter will always work,
since no two requests to a sequence can get the same value (rollover
excluded). If you must use timestamp, then you must auto-retry the insert
if the first attempt fails. Oracle does have higher precision than seconds,
but I can remember the exact precision ... I am pretty sure it works out to
at least two or three digits though.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
Tangosol Server: Enabling enterprise application customization
"Sajan Parihar" <[email protected]> wrote in message
news:[email protected]...
>
> hi all,
> I am trying to submit a form . Now whenever I click submit before I
insert any
> data sent in that form I make a check (SELECT stmt. to see if that record
can
> be inserted ...few business validations..) and if the check is successful
I then
> proceed for the necessary insert into a table the Primary key for which is
a running
> Oracle sequence.
> But if I click on the Submit button twice in close succession I have
observed
> may be 1 in 1000 attempts I am able to submit two records with the same
time stamp
> for the date of insertion . We are using Oracle 8 with weblogic 5.1. And I
don't
> think ORACLE's date precision is beyond seconds.
> So any suggestion ..what is the best way to handle such things : one
can be
> to place the same business validation check just before the ending brace
of the
> method , or secondly sucmit the form thru javascript and don't submit it
twice
> even if the user clicks the submit button twice... any suggestion which u
can
> give .. are welcome.
>
> thnx in advance
> sajan
-
Issue with dateformat in oracle
Hi,
I am using the java simpledateformat in my code like this
SimpleDateFormat Sformat = new SimpleDateFormat("yyyy-MM-dd");
String format_datenow = Sformat.format(new Date());
when I run the query on my database with format_datenow I get an error of invalid month, I tried changing the format to 'yyyy-MMM-dd' after seeing the column in the table displaying the 3 letter month like that, but still get the error.
I also tried to keep the original format and change the format in the oracle database: alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
but its still failing .. where is the issue currently..?Try using TO_CHAR function for the date you are fetching. In your case, use TO_CHAR(>DATE_COLUMN>,'YYYY-MM-DD'). Error is coming from the database where you are not correctly using TO_CHAR function. Once date is fetched from database, now you can format it in java in format whatever you want.
Salman -
Problem with DateFormat.parse
hi,
I'm working using Java 1.5.
i'm using SimpleDateFormat to parse date strings. My program has the following piece of code:
Class DateConverter {
SimpleDateFormat m_sdate = null ;
public DateConverter() {
this.m_sdate = new SimpleDateFormat("yyyyMMdd") ;
public Date to_date(String dstr) {
return this.m_sdate.parse(dstr) ;
The date parsing works fine as long as I give dates upto "00010101" but throws java.text.ParseException for the value "00001231". I was just eager to know whether 00010101 is the least date that can be parsed???
Thanks,
VenkateshI don't get a ParseException with your code; if there is an earliest date that can be parsed it's not 1/1/1.fmt = new SimpleDateFormat("yyyy/MM/dd");
new SimpleDateFormat("dd.MM.y G").format(fmt.parse("0/12/31"));
output: <31.12.01 BC> -
Calendar function with DateFormat
Hello,
I am trying to make a program that will use the time to tell me how much time I have until certain events that I enter. I use JCreator and I'm using the BreezySwing class for my GUI stuff since that's really the only GUI class I'm familiar with. After a few hours of poking around trying to get a feel for how the 2 classes work together by digging around in the documentation, I finally came up with a simple line to just tell the time. Basically it displays the time into a text area with Calendar.VARIABLE variables (i.e. DAY,HOUR,SECOND, etc.).
It kind of worked the first time, but the problem is that it got a Calendar instance the first time I ran it, and then it still is continuing to use that same instance every time I run it and no matter how I tweak it. I tried putting:
Calendar.getInstance() and putting that into a variable and using Format to format that variable but it still doesn't change the time at all. So I was thinking maybe it cached something and was using that, so I rebooted. No change. I shut down for the night and now again it is still the same.
Any ideas?This may help you.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
public class CalculateDay {
public static void print_date(String s)
System.out.println(s);
public static void print_date()
System.out.println();
public static void doDate()
/*CURRENT DATE & TIME*/
print_date("Current Date/Time:");
print_date();
Date now=new Date();
print_date(" - : "+now);
/*Calculate DAY*/
print_date();
print_date("PARSE STRING TO DATE");
print_date();
Date newDate;
String inputDate = JOptionPane.showInputDialog("Enter input as\n yyyy-MM-dd format");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
System.out.print(" - : " + inputDate + " parses as ");
try {
newDate = formatter.parse(inputDate);
print_date(newDate + ".");
} catch (ParseException e) {
print_date("Unparseable using " + formatter + ".");
print_date();
public static void main(String[] args) {
doDate();
System.exit(0);
} -
Fill fields with actual date / timestamp with button
Hello,
I did not find an answer for my following problem.
I want to put a button my adobe form that fills automactically three fields with data from the PC which are:
actual time (of the PC and of course timezone info), date and username, so the User has to press one button to fill all these data for convenience.
So I think it is necessary to program this in JavaScript as an "on-click" action. Since I'am not too much familiar with this, it would be great if someone can post a little sample coding for this (or has some other tipp).
regards and happy xmas
Jörgyou must have target fields for your Date, Time and Username, for example you have a structure in your data view called "ZINFO" with the fields "EDATE", "ETIME","ENAME"
in your layout you need a button where you click on
in the click event you can fill your fields (formcalc)
xfa.resolveNode("xfa.record.ZINFO.EDATE").value = Num2Date(Date(), "DD/MM/YYYY");
xfa.resolveNode("xfa.record.ZINFO.ETIME").value = Num2Time(Time(), "HH:MM:SS", "de_DE");
so you always get time/date when clicking
but how do you know who has opened the form?? did you realize some password protection??
br norbert -
Calendar Class with DateFormat
Hello,
I thought I posted this message before, but I can't find it. I'm dead tired so please let me know if I make this too short to follow. I am making a GUI program using BreezySwing (the only GUI class I know), and I am going to have it use the time to tell me how far away certain events that I input are. After digging in the documentation for a few hours :( and playing around with it to get a feel, and I ended up coming up with a line of code that gives the time with Calendar.VARIABLE variables (i.e. HOUR, MINUTE, SECOND, etc). I am putting those variables into a message in a text area. The problem, which persists even when I put a Calendar.getInstance() in, is that it always returns/displays the same time. I wondered about it caching something, so I rebooted and even shut down overnight and still SAME TIME.
Any ideas? I am just doing this for fun from my year of Java in high school a couple years ago for now but I am leaning toward majoring in CS now in college so I will want to get a thorough knowledge (if that matters in your response).
Thanks in advance,
ShaunYou'll probably get a better response if you post the
code you've tried so far...I know you want to help. Let me just advise you that bringing up days-old threads are somewhat an exercise in futility, and also be aware that by looking at the posting history you can see that the OP duplicated this and received responses on the duplicate. -
Has anyone encountered this issue before,
<cfset strDateTime = DateFormat(DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, Now()),"yyyy-mm-dd HH:mm:ss")>
<cfset TestDate = DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, Now())>
Output
=============================================
Date1 = {ts '2010-02-05 22:21:54'}
Date2 = 2010-02-05 22:02:54
How come the output for minutes stays the same on #strDateTime# everytime i run it?"yyyy-mm-dd HH:mm:ss")>
The DateFormat() masks do not have a "minutes" portion. So the "m" is actually returning the month not minutes. You have to use DateFormat() + TimeFormat(). -
Calendar, Timestamp, TimeZone and DateFormat
I need to persist date and time with a time zone information into database. In the application, I use the Calendar to represent the data and converse it to java.sql.Timestamp when I need to store the date into DB, use its reversed process to retrieve the data. The following process works for my need in some degree.
1. create a Calendar instance
2. convert it to Timestamp to match the DB field type and save into DB
3. retrieve the field from DB and convert back to Calendar (from Timestamp)
4. process the data with DateFormat for a given TimeZone GMT
My problem with the above approach is that it yields an incorrect data when a date time in DB is already in time zone GMT stored by another system process.
What is a good approach in the regard?
Thanks for your information in advance.Isn't Timestamp always "in UTC"? If you want to remember a TimeZone, would you need to store that separately?
Then again, I have this vague recollection there's a database type that combines timestamp and timezone, but does your DBMS have it?
Maybe you are looking for
-
Basically I bought a mini HDMI to normal sized for my celcus TV, I'm wondering if I have to do anything special asit won't show on my TV screen, if anyone could help I'd be extremely grateful, even to point me in the right direction if the lead I hav
-
Program to upload contract price changes to inforecord
Hi Friends, Is there any standard program available to update changes in contract price to info record I know if you put info update indicator in contract system will update provided you have EVO parameter set in id But i would like to know if we can
-
Restricting Changes in Purchase Order
We have a scenario where we do not want to use release strategy owing to vast no of transactions in Purchase Order creation. But we want to restrict users to make changes in Purchase Order afte one day of Purchase Order Creation. For Ex : if a user h
-
Flexible Appraisal template screen changes
Hi There, We are using Standard Flexible appraisal template based appraisal Solution EHP4. Now we have created a template to cater multi level details for each Objective. Structure looks like Objetive 1 Add/Delete Objective details 1.1 Add/Dele
-
Need advise - compare specified date in *.sql with sysdate.
Hi Guys, Need help here. Anyone has a script that will compare the specified date with the current sysdate. If earlier, it will order SQL*PLUS to quit immediate. Basically the checking will be in a *.sql script. Whenever we run the script, @c:\script