How to get the hour:minuts:seconds using java
I have table xydata
here i get the gsTime like this 2010-04-21 10:58:40
the above time i want to get only 10:58:40
how to write the java for this
please help me
Thanks in Advance
Problem of this sort cry out for using regular expressions. It is what they were invented for. If the OP wanted the whole date parsed into a java.util.Date then it would be a different matter and SimpleDateFormat would be the way to go but extracting part of a string is what regular expressions are best at.
In this case, even a regular expression approach is far too complex. Which of the following do you consider the most appropriate ?
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Sabre20100508
public static void main(String[] args) throws Exception
String[] lines =
"2010-04-21 11:01:35",
"2010-04-21 11:01:58",
"2010-04-21 11:02:21",
"2010-04-21 11:02:42",
"2010-04-21 11:03:28",
"2010-04-21 11:03:51"
Pattern p = Pattern.compile("(?<= )\\d{2}:\\d{2}:\\d{2}");
System.out.println("Method 1 :-");
for (String line : lines)
Matcher m = p.matcher(line);
if (m.find())
System.out.printf(" [%s]\n", m.group());
Pattern p = Pattern.compile("\\d{4}-\\d{2}-\\d{2} (\\d{2}:\\d{2}:\\d{2})");
System.out.println("Method 2 :-");
for (String line : lines)
Matcher m = p.matcher(line);
if (m.matches())
System.out.printf(" [%s]\n", m.group(1));
System.out.println("Method 3 :-");
for (String line : lines)
String[] splitLIne = line.split(" ", 2);
System.out.printf(" [%s]\n", splitLIne[1]);
System.out.println("Method 4 :-");
for (String line : lines)
int index = line.lastIndexOf(" ");
System.out.printf(" [%s]\n", line.substring(index + 1));
System.out.println("Method 5 :-");
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
for (String line : lines)
Date date = parser.parse(line);
System.out.printf(" [%s]\n", formatter.format(date));
System.out.println("Method 6 :-");
for (String line : lines)
System.out.printf(" [%s]\n", line.replaceAll("[^ ]* ", ""));
}My vote goes to method 4!
Similar Messages
-
Displaying the hour, minute, seconds.....
Hi fellow experts!
Once again I call upon you for help. I'm strugglng with the formatting of dates...specifically the hour, minute, seconds between two dates.
Sample data:
create table test (script_name varchar2(50),run_start date,run_end date, job_id number, parent_job_id number);
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMPORTMTM','09-FEB-10','09-FEB-10','2409671','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('INT_EOD_VALUATIONS','09-FEB-10','09-FEB-10','2409673','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('ACC_EOD_FXACCOUNTING','09-FEB-10','09-FEB-10','2409677','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FXUPDATE ','09-FEB-10','09-FEB-10','2409679','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('MX_PREACCOUNTING_BACKUP_RP','09-FEB-10','09-FEB-10','2409683','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('DM_PREACCOUNTING_BACKUP_RP','09-FEB-10','09-FEB-10','2409684','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMP_FIXING','09-FEB-10','09-FEB-10','2409688','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FIXINGIRD','09-FEB-10','09-FEB-10','2409690','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('WAIT_5_MINS','09-FEB-10','09-FEB-10','2409692','2409645');
The output of the time should look like the results from the query below:
select floor((run_end-run_start)*24) as Hrs ,floor(((run_end-run_start)*1440 - floor((run_end-run_start)*24)*60)) as Mins,
ceil(((run_end-run_start)*86400 - floor((run_end-run_start)*1440)*60)) as Secs
from (
select to_date('10-oct-2003 15:02:23','DD-Mon-YYYY HH24:Mi:SS') as run_start,
to_date('10-oct-2003 16:20:20','DD-Mon-YYYY HH24:Mi:SS') as run_end
from dual);
i.e
H M S
1 17 57
My current sql is:
select script_name,
run_start,
run_end,
floor((run_end-run_start)*24) as Hrs ,floor(((run_end-run_start)*1440 - floor((run_end-run_start)*24)*60)) as Mins,
ceil(((run_end-run_start)*86400 - floor((run_end-run_start)*1440)*60)) as Secs
from (
select lpad(' ',5*level,' ')||name script_name
,to_date(run_start,'dd-mon-yyyy hh24:mi:ss') run_start, to_date(run_end,'dd-mon-yyyy hh24:mi:ss') run_end,
sys_connect_by_path(to_date(run_start,'dd-mon-yyyy hh24:mi:ss'),'/') root_start
from jcs_jobs
connect by prior job_id = parent_job_id
start with PARENT_JOB_ID IS NULL and job_id = 2409645
I need a slight tweak somewhere, but can't quite get there!
Oracle version is 9i
Many thanks for your help in advance.
DevHi,
Devski Peters wrote:
......sorry, I didn't make myself clear.....Sorry, this message made things even less clear.
Like Bhushan, I don't see any relationship between the data you posted:
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMPORTMTM','09-feb-2010 20:00:02','09-feb-2010 20:00:44','2409671','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('INT_EOD_VALUATIONS','09-feb-2010 20:00:44','09-feb-2010 20:01:03','2409673','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('ACC_EOD_FXACCOUNTING','09-feb-2010 20:01:05','09-feb-2010 20:01:24','2409677','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FXUPDATE ','09-feb-2010 20:01:24','09-feb-2010 20:01:43','2409679','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('MX_PREACCOUNTING_BACKUP_RP','09-feb-2010 20:01:45','09-feb-2010 20:01:49','2409683','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('DM_PREACCOUNTING_BACKUP_RP','09-feb-2010 20:01:45','09-feb-2010 20:01:49','2409684','2409645');
insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMP_FIXING','09-feb-2010 20:01:51','09-feb-2010 20:02:15','2409688','2409645');and the results you want:
NORMAL_DAY 09-feb-2010 18:05:00 10-feb-2010 04:22:45 20'681'879.88
Step 1 of NORMAL_DAY 09-feb-2010 18:05:00 09-feb-2010 18:05:24 575.88
Step 2 of NORMAL_DAY 09-feb-2010 18:05:24 09-feb-2010 18:05:46 527.88
EOD_FX_RATE_UPLOAD 09-feb-2010 18:05:24 09-feb-2010 18:05:46 527.88
Step 1 of EOD_FX_RATE_UPLOAD 09-feb-2010 18:05:24 09-feb-2010 18:05:30 143.88
FX_FTPS_GET_EOD 09-feb-2010 18:05:26 09-feb-2010 18:05:30 95.88
Step 2 of EOD_FX_RATE_UPLOAD 09-feb-2010 18:05:30 09-feb-2010 18:05:45 359.88
FXSPOTS 09-feb-2010 18:05:31 09-feb-2010 18:05:45 335.88
Step 3 of EOD_FX_RATE_UPLOAD 09-feb-2010 18:05:45 09-feb-2010 18:05:46 23.88
SEND_MAIL_FXSPOTS 09-feb-2010 18:05:45 09-feb-2010 18:05:46 23.88
Step 3 of NORMAL_DAY 09-feb-2010 18:05:46 09-feb-2010 18:06:10 1'535.88
CALENDAR_UPLOAD 09-feb-2010 18:05:47 09-feb-2010 18:06:10 1'511.88
Step 1 of CALENDAR_UPLOAD 09-feb-2010 18:05:47 09-feb-2010 18:05:53 143.88
CALENDAR 09-feb-2010 18:05:47 09-feb-2010 18:05:53 143.88
Step 2 of CALENDAR_UPLOAD 09-feb-2010 18:05:53 09-feb-2010 18:06:00 1'127.88
MDS_STOP 09-feb-2010 18:05:53 09-feb-2010 18:06:00 1'127.88
Step 3 of CALENDAR_UPLOAD 09-feb-2010 18:06:00 09-feb-2010 18:06:03 71.88
MDS_HOLIDAY 09-feb-2010 18:06:00 09-feb-2010 18:06:03 71.88
Step 4 of CALENDAR_UPLOAD 09-feb-2010 18:06:03 09-feb-2010 18:06:10 167.88Do you really want that data to produce that output?
If the results are not from that data, then post a consistent set of data and results.
When you have poted some sample data and the results you want from that data , explain how you get those results. Pick a couple of rows of output, and explain how you got every column in the results from the data. Be specific.
The table has a 'pig ear' relationship......so job_id can have the same parent_job_id.....What is a "pig ear" relationship? (I like the name.)
>
The connect by allows me display the results with indentation, so the results will look like:The results look completely unformatted on my browser.
When you post any formatted text on this site, type these 6 characters:
(small letters only, inside curly brackets) before and after each formatted section.
So for example,the first line shows a time of 20'681'879.88, which works out to 10:18 hours approx. Explain the relationship between 20'681'879.88 and "10:18 hours". (Do you mean 10 hours plus 18 minutes?) -
Save date with precision (Hour, Minutes, seconds ) using V.O.
Hi all,
I'm using Jdeveloper 11g.
I have an Entity object with a column called 'createdOn' of type Date and an entity based View Object with the same type.
I'm trying to save today's Date with precision (day, month, year, hour, minutes, seconds) Using the view Object, but when I look in the Data Base, always appears the date without time.
Here is my code in the application Module to save the data, I've tried some things but nothing...
First I've tried using oracle.jbo.domain.Date, and I've tryed using Calendar as well. Nothing with
ViewObjectImpl voSample = getSamples1View1();
//Date creation for View Object
oracle.jbo.domain.Date today = new Date(Date.getCurrentDate());
//Calendar today = Calendar.getInstance();
//loop through the list of samples (TESTGROUPTYPES), and create the objects
while( it.hasNext())
Row rowSample = voSample.createRow();
SequenceImpl sequence = new SequenceImpl("SAMPLES_SEQ", voSample.getApplicationModule());
rowSample.setAttribute("SampleId", sequence.getSequenceNumber());
rowSample.setAttribute("CollectionId", stCollectionId);
rowSample.setAttribute("TestgroupType",it.next());
rowSample.setAttribute("UnitId",stUnitId);
rowSample.setAttribute("SampleStatus", "ORDERED");
rowSample.setAttribute("SampleBackup", "false");
rowSample.setAttribute("CreatedOn", today);
voSample.insertRow(rowSample);
voSample.getApplicationModule().getTransaction().commit();
Any help will be usefull,
thanks in advance
XAVI.Hello John,
yes, I changed the date mask using
alter session set NLS_DATE_FORMAT='DD/MM/YYYY-hh24:mi:ss'
if i execute to_char(<date_column>, 'YY-MON-DD HH:MI:SS') on that column, the result is:
09-MAY-27 12:00:00
09-MAY-27 12:00:00
09-MAY-27 12:00:00
To launch the queries and see the results I'm using the JDeveloper's SQL WorkSheet.
I can update the data and time and the time persists in the DB
08-FEB-26 08:07:56
so, i think there's something in hte EO, VO or App Module method that I'm doing wrong...
The Entity Attribute is confirured:
name: CreatedOn
Type: Date
Value type: literal
Values checked: Persistent, Precision Rule and Queryable
database column: CREATED_ON, type: DATE
The View attribute is configured:
Name: CreatedOn
Type: Date
Value type: Literal
checked: Mapped to Column or SQL, Selected in query, queryable
query column: Alias: CREATED_ON, Type: DATE -
How to get the current GMT time in java
Hi,
How to get the current GMT time in java
ThanksSystem.getCurrentTimeMillis() or new Date().
[url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
[url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format -
How to get the profile object in simple java class (Property accessor)
Hi All,
Please guide me how to get the profile object in simple java class (Property accessor) which is extending the RepositoryPropertyDescriptor.
I have one requirement where i need the profile object i.e i have store id which is tied to profile .so i need the profile object in the property accessor of the SKU item descriptor property, which is extending RepositoryPropertyDescriptor.
a.I dont have request object also to do request.resolvename.
b.It is not a component to create setter and getter.It is simple java class which is extending the RepositoryPropertyDescriptor.
Advance Thanks.Iam afraid you might run into synchronization issues with it. You are trying to get/set value of property of a sku repository item that is shared across various profiles.
Say one profile A called setPropertyValue("propertyName", value).Now another profile B accesses
getPropertyValue() {
super.getPropertyValue() // Chance of getting value set by Profile A.
// Perform logic
There is a chance that profile B getting the value set by Profile A and hence inconsistency.
How about doing this way??
Create PropertyDescriptor in Profile (i.e user item descriptor), pass the attribute CustomCatalogTools in userProfile.xml to that property.
<attribute name="catalogTools" value="atg.commerce.catalog.CustomCatalogTools"/>
getPropertyValue()
//You have Profile item descriptor and also storeId property value.
// Use CustomCatalogTools.findSku();
// Use storeId, profile repository item, sku repository item to perform the logic
Here user itemdescriptor getPropertyValue/setPropertyValue is always called by same profile and there is consistency.
-karthik -
In OBIEE 11G, how to get the special parameter created by JAVA?
Hi Experts,
In OBIEE 11G, how to get the special parameter created by JAVA?
For example:
In JAVA , it has set one parameter named 'test'.
So how to get the parameter in filter area in OBIEE?Hi Kobe,
No P2 holds the parameter name like PresentationTable.ColumnName, in your form you may go for complete name or just column name and before submitting the form you can define the Action url.
I would suggest to read section 6.3.2.1.
ex:
<SCRIPT LANGUAGE="JavaScript">
changeAction(url) {
var TestVar = form.inputbox.value;
document.this_form.action="saw.dll?Go&Path=/Shared/Test/SB2&Action=Navigate&P0=1&P1=like&P2=Customers.Region&P3="+TestVar;
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="button" Value="Click" onClick="changeAction(this.value)">
</FORM>
If helps pls mark.
Edited by: veeravalli on Oct 24, 2012 10:25 AM -
How to get the current function name in java
How to get the current function name in java.
In c it is done as
printf("%s",__func__);
Thanx in advance.j0o wrote:
System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
"/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
"/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes! -
How to force the Netscape browser to use Java Plug-in 1.3.0_02?
For Analyzer 6.2.1, how to force the Netscape browser to use Java Plug-in 1.3.0_02?
Change the classid in the object tag here is some info.This applies to JRE's 1.3.1 and greater.How do I know what Class ID to use for a specific JRE?CAFEEFAC-0013-0001-0004-ABCDEFFEDCBACAFEEFAC = This tells the browser to force a specific JRE0013-0001-0004 = JRE version number 1.3.1_04 (1.3.1_08 would be 0013-0001-0008)ABCDEFFEDCBA = Just needs to be there.1.3.0_02 = E19F9331-3110-11d4-991C-005004D3B3DB, it seems like they did not implement the standard until v.1.3.1Any good JRE Version = 8AD9C840-044E-11D1-B3E9-00805F499D93, this class id will just look for any good JRE.http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/version.html
-
How to get the hour glass in the GUI status bar.
Hi all,
how can I get the hour glass and a corresponding text in the GUI status bar? Like during the compilation I would like to show a message 'Processing data ...'.
Best regards,
NilsA good example is provided in https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap code samples/abap objects/abap code sample progress indicator.pdf
-
[CS2]How to get the Image Width & Height using JS (ILLUSTRATOR CS2)
Hi,
How to get the Image width & height of an Image using javascript .Im using Illustrator CS2.
Any sample code
Regards
MyRiazyou can reference the dimensions of a loading image (or swf)
by referencing the target movieclip's dimensions AFTER loading is
complete. ie, use preloader code or the onLoadInit() method of a
moviecliploader listener. -
How to get the update file without using Nokia Sof...
The network connection is unreliable and downloading the firmware update using PC Suite for my Nokia E90 proves difficult. Does anyone know how I can get the firmware version 300.34.84?
The trouble is Nokia's Software Updater does not accommodate any slight interruption to the connection during the update process. I will update this discussion with what version of PC Suite I have once I get that info.
Any help is kindly appreciatedIn fact, it is not Possible to get the update file without using Nokia Software Updater or you should search the net to find the update files in another place and even you get them, you can not use them with NSU.
You can Update your Device with:
1 - NSU (Nokia Software Update)
2 - FOTA (Firmware Over The Air) for FP2 devices ONLY.
3 - Nokia Care Center
there is not other way to upgrade.
Hope useful for u.
regards
Nokia N79 4GB
SW Version: 32.001 RM-348 MEA -
Quick question: How to get the scrolled page number using af:table
Hi,
When using range paging on scrolled table, how to get the current scrolled page number(1,2,3...), for example when moving the table vertical scroll bar forward or backward, is there any method in ViewObjectImpl class that I can use to get such information? I have seen the method scrollToRangePage(int i), but when scrolled ("Fetching data..."), it doesn't not get into this method. So it is wrong usage for this method, right?
ThanksDidn't you just ask that question in this thread?: How to catch the page number when using scroll table in ADF 11g?
A bit of patience might be in order.
CM. -
Regarding: How to get the Tax Breakup Amount using SDK
Hai Friends,
I created one saled order . I have given Tax code (Service) then it show total amout of tax is 370.80. when i click the link button of Tax Amount field from sales order then it show the Tax Breakup Details in Separate Screen of SAP. That screen Contain following Details.
From Caption is : Define Tax Amount Distribution
Type Tax Parameter Code Tax Parameter Name Rate Duty Tax Amount Base Amount
Service Service Service Tax 12 360.00
Cess_ST Cess_ST Education Cess for Sevice 2 7.20
HSCess_ST HSC_ST HSCee for Service 1 1.00
My Doupt is :
How do i get the Service tax Breakup value from above grid.
How to get the Tax Breakup value from that SAP Screen, is it any help in SDK.
Please Help Me.
Regards,
K Sakthivel
Edited by: ksakthivel on Dec 7, 2011 10:41 AM
Edited by: ksakthivel on Dec 7, 2011 10:53 AM
Edited by: ksakthivel on Dec 7, 2011 10:54 AMHai Friends,
I created one saled order . I have given Tax code (Service) then it show total amout of tax is 370.80. when i click the link button of Tax Amount field from sales order then it show the Tax Breakup Details in Separate Screen of SAP. That screen Contain following Details.
From Caption is : Define Tax Amount Distribution
Type Tax Parameter Code Tax Parameter Name Rate Duty Tax Amount Base Amount
Service Service Service Tax 12 360.00
Cess_ST Cess_ST Education Cess for Sevice 2 7.20
HSCess_ST HSC_ST HSCee for Service 1 1.00
My Doupt is :
How do i get the Service tax Breakup value from above grid.
How to get the Tax Breakup value from that SAP Screen, is it any help in SDK.
Please Help Me.
Regards,
K Sakthivel
Edited by: ksakthivel on Dec 7, 2011 10:41 AM
Edited by: ksakthivel on Dec 7, 2011 10:53 AM
Edited by: ksakthivel on Dec 7, 2011 10:54 AM -
How to get the silverish white color in Java
Hi
I want to know how to get the silver color in Java
I am currently using
R , G , B
setBackground(new color(255,255,255));
I am getting bright white color.
How do I get the polished white(silverish white color) color.
Thank YouRGB Color Chart...
http://www.htmlcenter.com/tutorials/tutorials.cfm/89/General/
perhaps new Color(223,223,255) ??? -
How to get the system32 folder path in java?
how to get the system32 folder path in windows using java code?
Zstar Electronic Co.Ltd, Wholesaler of fire cards for DS/NDSL/NDSi, Provide R4, R4i, DStt, iEDGE, AK2i,M3,M3i,N5
www.zstar.hk
Maybe you are looking for
-
Can I use a stylus on an iPad.?.
Can I use a stylus with an iPad.
-
Some sites(like youtube for instance) want me to update Safari but when I go to Software Update under the apple it says there are no updates. What do I do now?
-
International characters from HttpServletRequest - getPathInfo
Hello, we have a very peculiar problem, we need to get parameters from the querystring (HttpServletRequest), however we use a different delimiter than the ampersand (&) to parse our own parameters. To get the parameters we use the getPathInfo method
-
Pre-Order Tom Clancy's The Division Online Now to get BETA access and bonus content!
Ubisoft is once again set to bring another Tom Clancy game to the masses. This time they are poised to bring gamers something fresh and are going to push the boundaries of what we consider gaming. Tom Clancy's The Division is the upcoming massively m
-
Throttling the JMS Transport in OSB
Hi All, I have a requirement if i have 10 messages in the JMS Queue . If i create a proxy service it should read one message at a time . How will i configure this in JMSTransport . I know how to do this JMSAdapter . Thanks Phani