Java Date Comparison
Hi, I want to compare two dates without including the time. I just want do see if Date A == Date B, regardless of what the time is. Thank you
cotton.m wrote:
CaptainMorgan08 wrote:
java_swing_dude wrote:
Fabulous, you are an amazing aid.I even gave you a link to the API in the last date question you asked, but you apparently didn't look at it then either. The API is one of the best resources you will find.I guess swinging dude here just wants teh codez ™. Which is ironic since he got teh codez™ in his last thread and they did him no good whatsoever.
The moral of the story is that he's very lucky to have access to an amazing aid like myself to straighten him out. Now if only he assigned me those promised 10 duke stars we'd be all set.Well he didn't assign them out in the other thread, so... :shrug:
Similar Messages
-
Data comparisons and movements
I have a Heap Sort using the following code, and I cannot seem to figure out how many data comparisons and data movements there are as the heap is sorted. Does anybody know how to count the number of comparisons and movements?? Please let me know....much appreciated...Thanks :)
import java.io.IOException;
import java.util.*; // Calender Class for timing
public class Heap {
private MyNode[] heapArray;
private int maxSize;
private int currentSize; // number of items in array
public Heap(int mx) {
maxSize = mx;
currentSize = 0;
heapArray = new MyNode[maxSize];
public MyNode remove()
MyNode root = heapArray[0];
heapArray[0] = heapArray[--currentSize];
trickleDown(0);
return root;
public void trickleDown(int index) {
int largerChild;
MyNode top = heapArray[index];
while (index < currentSize / 2)
int leftChild = 2 * index + 1;
int rightChild = leftChild + 1;
// find larger child
if (rightChild < currentSize
heapArray[leftChild].getKey() < heapArray[rightChild]
.getKey())
largerChild = rightChild;
else
largerChild = leftChild;
if (top.getKey() >= heapArray[largerChild].getKey())
break;
heapArray[index] = heapArray[largerChild];
index = largerChild;
heapArray[index] = top;
public void displayHeap() {
int nBlanks = 32;
int itemsPerRow = 1;
int column = 0;
int currentIndex = 0;
while (currentSize > 0)
if (column == 0)
for (int k = 0; k < nBlanks; k++)
System.out.print(' ');
System.out.print(heapArray[currentIndex].getKey());
if (++currentIndex == currentSize) // done?
break;
if (++column == itemsPerRow) // end of row?
nBlanks /= 2;
itemsPerRow *= 2;
column = 0;
System.out.println();
else
for (int k = 0; k < nBlanks * 2 - 2; k++)
System.out.print(' '); // interim blanks
public void displayArray() {
for (int j = 0; j < maxSize; j++)
System.out.print(heapArray[j].getKey() + " ");
System.out.println("");
public void insertAt(int index, MyNode newNode) {
heapArray[index] = newNode;
public void incrementSize() {
currentSize++;
public static void main(String[] args) throws IOException {
int size, i;
size = 500;
Heap theHeap = new Heap(size);
for (i = 0; i < size; i++) {
int random = (int) (java.lang.Math.random() * 5000);
MyNode newNode = new MyNode(random);
theHeap.insertAt(i, newNode);
theHeap.incrementSize();
System.out.println(size+" random numbers are currently being generated...");
for (i = size / 2 - 1; i >= 0; i--)
theHeap.trickleDown(i); // creates the heap
System.out.print("\nRandom Numbers in a Heap: ");
theHeap.displayArray(); // prints the heap
long time1000start = new Date().getTime() ; // this makes a new Date object and then sets the long integer value of the Date object
// ******************* START - sorting numbers *******************
for (i = size - 1; i >= 0; i--)
MyNode biggestNode = theHeap.remove();
theHeap.insertAt(i, biggestNode);
// ******************* END - sorting numbers *******************
long time1000end = new Date().getTime() ; // this makes a new Date object and then sets the long integer value of the Date object
double timediff1000m = (time1000end - time1000start); // difference of time in milliseconds
double timediff1000s = ((time1000end - time1000start) / 1000); // difference of time in seconds
System.out.print("\nRandom Numbers in a Sort: ");
theHeap.displayArray(); // prints the numbers in increasing order
System.out.print("\nStart Time of Sort: "+time1000start);
System.out.print("\nEnd Time of Sort: "+time1000end);
System.out.print("\nTime to Complete Sort: "+timediff1000m+" milliseconds or "+timediff1000s+" seconds.");
} // end main method
} // END project :)I never miss class....my instructor gave us the assignment of making a heap sort and he told us to use code off the internet as a resource because the only sorting we have done so far is bubble.....this was a research project, for my instructor to see if we can use the internet as an effective resource to put together a program and learn about a differnet type of sorting.....everyone in the class got a different type of sort (merge, quick, insertion, etc...). i have put the program together and customized it to my needs based on my knowledge.....the last thing i am having trouble with is my counting of comparisons and data movements. Can you please help me finish up my program.
-
How to do sorting/filtering on custom java data source implementation
Hi,
I have an entity driven view object whose data should be retrieved and populated using custom java data source implementation. I've done the same as said in document. I understand that Query mode should be the default one (i.e. database tables) and createRowFromResultSet will be called as many times as it needs based on the no. of data retrieved from service, provided we should write the logic for hasNextForCollection(). Implementation sample code is given below.
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
Iterator datumItr = retrieveDataFromService(qc, params);
setUserDataForCollection(qc, datumItr);
hasNextForCollection(qc);
super.executeQueryForCollection(qc, params, noUserParams);
protected boolean hasNextForCollection(Object qc) {
Iterator datumItr = (Iterator) getUserDataForCollection(qc);
if (datumItr != null && datumItr.hasNext()){
return true;
setCallService(false);
setFetchCompleteForCollection(qc, true);
return false;
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet resultSet) {
Iterator datumItr = (Iterator) getUserDataForCollection(qc);
Object datumObj = datumItr.next();
ViewRowImpl r = createNewRowForCollection(qc);
return r;
Everything is working fine include table sorting/filtering. Then i noticed that everytime when user perform sorting/filtering, executeQueryForCollection is called, which in turn calls my service. It is a performance issue. I want to avoid. So i did some modification in the implementation in such a way that, service call will happen only if the callService flag is set to true, followed by executeQuery(). Code is given below.
private boolean callService = false;
public void setCallService(boolean callService){
this.callService = callService;
public boolean isCallService(){
return callService;
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams){
if (callService)
Iterator datumItr = retrieveDataFromService(qc, params);
setUserDataForCollection(qc, datumItr);
hasNextForCollection(qc);
super.executeQueryForCollection(qc, params, noUserParams);
Issue i have:
When user attempts to use table sort/filter, since i skipped the service call and set null as userDataCollection, createRowFromResultSet is not called and data which i retrieved and populated to view object is totally got vanished!!. I've already retrived data and created row from result set. Why it should get vanished? Don't know why.
Tried solution:
I came to know that query mode should be set to Scan_Entity_Cache for filtering and Scan_View_Rows for sorting. I din't disturb the implementation (i.e. skipping service call) but overrided the executeQuery and did like the following code.
@Override
public void executeQuery(){
setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
super.executeQuery();
By doing this, i could able to do table filtering but when i try to use table sorting or programmatic sorting, sorting is not at all applied.
I changed the code like beolw*
@Override
public void executeQuery(){
setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
super.executeQuery();
Now sorting is working fine but filtering is not working in an expected way because Scan_View_rows will do further filtering of view rows.
Question:
I don't know how to achieve both filtering and sorting as well as skipping of service call too.
Can anyone help on this?? Thanks in advance.
RaguramanHi,
I have an entity driven view object whose data should be retrieved and populated using custom java data source implementation. I've done the same as said in document. I understand that Query mode should be the default one (i.e. database tables) and createRowFromResultSet will be called as many times as it needs based on the no. of data retrieved from service, provided we should write the logic for hasNextForCollection(). Implementation sample code is given below.
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
Iterator datumItr = retrieveDataFromService(qc, params);
setUserDataForCollection(qc, datumItr);
hasNextForCollection(qc);
super.executeQueryForCollection(qc, params, noUserParams);
protected boolean hasNextForCollection(Object qc) {
Iterator datumItr = (Iterator) getUserDataForCollection(qc);
if (datumItr != null && datumItr.hasNext()){
return true;
setFetchCompleteForCollection(qc, true);
return false;
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet resultSet) {
Iterator datumItr = (Iterator) getUserDataForCollection(qc);
Object datumObj = datumItr.next();
ViewRowImpl r = createNewRowForCollection(qc);
return r;
}Everything is working fine include table sorting/filtering. Then i noticed that everytime when user perform sorting/filtering, executeQueryForCollection is called, which in turn calls my service. It is a performance issue. I want to avoid. So i did some modification in the implementation in such a way that, service call will happen only if the callService flag is set to true, followed by executeQuery(). Code is given below.
private boolean callService = false;
public void setCallService(boolean callService){
this.callService = callService;
public boolean isCallService(){
return callService;
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams){
if (callService) {
Iterator datumItr = retrieveDataFromService(qc, params);
setUserDataForCollection(qc, datumItr);
hasNextForCollection(qc);
super.executeQueryForCollection(qc, params, noUserParams);
}Issue i have:
When user attempts to use table sort/filter, since i skipped the service call and storing of userDataCollection, createRowFromResultSet is not called and data which i retrieved and populated to view object is totally got vanished!!. I've already retrived data and created row from result set. Why it should get vanished? Don't know why.
Tried solution:
I came to know that query mode should be set to Scan_Entity_Cache for filtering and Scan_View_Rows for sorting. I din't disturb the implementation (i.e. skipping service call) but overrided the executeQuery and did like the following code.
@Override
public void executeQuery(){
setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
super.executeQuery();
}By doing this, i could able to do table filtering but when i try to use table sorting or programmatic sorting, sorting is not at all getting applied.
I changed the code like below one (i.e. changed to ViewObject.QUERY_MODE_SCAN_VIEW_ROWS instead of ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS)
@Override
public void executeQuery(){
setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
super.executeQuery();
}Now sorting is working fine but filtering is not working in an expected way because Scan_View_rows will do further filtering of view rows.
If i OR'ed the Query Mode as given below, i am getting duplicate rows. (vewObject.QUERY_MODE_SCAN_ENTITY_ROWS | ViewObject.QUERY_MODE_SCAN_VIEW_ROWS) Question:
I don't know how to achieve both filtering and sorting as well as skipping of service call too.
Can anyone help on this?? Thanks in advance.
Raguraman
Edited by: Raguraman on Apr 12, 2011 6:53 AM -
Simple java date related question
Hi Friends,
I have written this custom date class that compares two dates. The user can enter any number of days,and it should calculate the next date,is that possible???
public class Date implements Comparable {
private int month, day, year;
public Date(int m, int d, int y) {
month = m;
day = d;
year = y;
public int compareTo(Object o) {
Date a = this;
Date b = (Date) o;
if (a.year < b.year) return -1;
if (a.year > b.year) return 1;
if (a.month < b.month) return -1;
if (a.month > b.month) return 1;
if (a.day < b.day) return -1;
if (a.day > b.day) return 1;
return 0;
public String toString() {
return month + "/" + day + "/" + year;
public static void main(String[] args) {
Date d1 = new Date(21, 03, 2007);
int days = Integer.parseInt(args[0]);
System.out.println("New date is:"); // Need to print new date
Expected output:
java Date 30
New date is: 04/20/2007If this is not possible with this class,how can we do this, any ideas.
Your help would be appreciated.
ThanksHi,
Try this code out:
import java.text.DateFormat;
import java.util.*;
import javax.swing.JOptionPane;
public class SimpleDate {
private int month, day, year;
public SimpleDate() {
Date date = new Date();
String myString = DateFormat.getDateInstance().format(date);
StringTokenizer tokens = new StringTokenizer(myString, "/");
day = Integer.parseInt(tokens.nextToken());
month = Integer.parseInt(tokens.nextToken());
year = Integer.parseInt(tokens.nextToken());
public SimpleDate(String stdate) {
try {
StringTokenizer tokens = new StringTokenizer(stdate, "/");
day = Integer.parseInt(tokens.nextToken());
month = Integer.parseInt(tokens.nextToken());
year = Integer.parseInt(tokens.nextToken());
catch(Exception e) {
Date date = new Date();
String myString = DateFormat.getDateInstance().format(date);
StringTokenizer tokens = new StringTokenizer(myString, "/");
day = Integer.parseInt(tokens.nextToken());
month = Integer.parseInt(tokens.nextToken());
year = Integer.parseInt(tokens.nextToken());
JOptionPane.showMessageDialog(null, "Invalid String,\nDate set to current", "Invalid String", JOptionPane.ERROR_MESSAGE);
public SimpleDate(int d, int m, int y) {
month = m;
day = d;
year = y;
public int compareTo(Object o) {
SimpleDate a = this;
SimpleDate b = (SimpleDate) o;
if (a.year < b.year) return -1;
if (a.year > b.year) return 1;
if (a.month < b.month) return -1;
if (a.month > b.month) return 1;
if (a.day < b.day) return -1;
if (a.day > b.day) return 1;
return 0;
private int getNumOfDaysInMonth() {
boolean leap = false;
int days = 30;
if (year % 4 == 0) leap = true;
if ((month == 1) | (month == 3) | (month == 5) | (month == 7) |
(month == 8) | (month == 10) | (month == 12)) {
days = 31;
if ((month == 4) | (month == 6) | (month == 9) | (month == 11)) {
days = 30;
if (month == 2) {
if (leap) {
days = 29;
else days = 28;
return days;
public void addDays(int nums) {
while (nums > getNumOfDaysInMonth()) {
nums = nums - getNumOfDaysInMonth();
addMonths(1);
day = day + nums;
while (day > getNumOfDaysInMonth()) {
day = day - getNumOfDaysInMonth();
addMonths(1);
public void addMonths(int nums) {
while (nums > 12) {
nums = nums - 12;
addYears(1);
month = month + nums;
while (month > 12) {
month = month - 12;
addYears(1);
public void addYears(int nums) {
year = year + 1;
public int getDay() {
return day;
public int getMonth() {
return month;
public int getYear() {
return year;
public String toString() {
return day + "/" + month + "/" + year;
}I have swapped the day and month around from mm/dd/yyyy to dd/mm/yyyy
but otherwise its still the same basic code -
Report customer master data comparison
Hello Experts,
Using transaction SE38, we would like to run report customer master data comparison. Could anyone provide the report name?
Thank youHi Thanks.
Can you provide report used for sales summary?
Thanks again -
Idoc data comparison between different R/3 clients.
Hi ppl ,
Is there a way idoc comparison can be done between different clients without going
by Segment by Segment comparison ?
I have a requirement wherein i have thousands of idocs in QA system and i need to
compare those with the ones in PROD system. The segments in the idocs may vary
depending on the data that flows from the third party system which will post idocs in R/3.
So, the segment wise comparison of data is also ruled out .
Do we have any standard reports which will help in achieving this purpose ?
Please let me know how the idoc data comparison can be carried out .
Regards,
Nick.Hi Nick,
There is no standared tools available for comparing the data of two idocs.
By using beyond compare s/w you can check the data, but the thing is you have to download the idoc data to file format.
By using Idoc_xml_transform function module you can download idoc data to xml format, after you can compare.
Check this
http://download.cnet.com/Beyond-Compare/3000-2242_4-10015731.html
Regards
Ramesh -
Issue with "firstRecord" Business Component method of JAVA Data bean API.
Hi,
Following is my use-case scenario:
I have to add or associate child MVG business component (CUT_Address)
with the parent business component (Account) using JAVA Data bean API.
My requirement is: first to check whether child business component(i.e. CUT_address) exists. If it exists then associate it with parent business component (Account)
otherwise create new CUT_address and associate it with account.
Code (using JAVA Data bean APIs) Goes as follows:
SiebelBusObject sBusObj = connBean.getBusObject("Account");
parentBusComp = sBusObj.getBusComp("Account");
SiebelBusComp parentBusComp;
SiebelBusComp childBusComp;
// retrieve required account.. Please assume Account1 exists
parentBusComp.activateField("Name");
parentBusComp.clearToQuery();
parentBusComp.setSearchSpec("Name", "Account1");
sBusComp.executeQuery2(true, true);
sBusComp.firstRecord();
Counter = 0;
while (counter < Number_Of_Child_Records_To_Insert)
childBusComp = parentBusComp.getMVGBusComp("City");
associatedChildBusComp = childBusComp.getAssocBusComp();
childBusComp.activateField("City");
childBusComp.clearToQuery();
childBusComp.setSearchSpec("City", Vector_of_city[counter]);
sBusComp.executeQuery2(true, true);
if( sBusComp.firstRecord() )
// Child already exist and do processing accordingly
else
// Child does not exist and do processing accordingly
childBusComp.release();
childBusComp = null;
associatedChildBusComp.release();
associatedChildBusComp=null;
Now the issue with this code is: For the first iteration, SbusComp.firstRecord returns 0 if records does not exist. However from the second iteration, SbusComp.firstRecord returns 1 even if there is no record matching the search specification.
Any input towards the issue is highly appreciable.
Thanks,
Rohit.Setting the view mode to "AllView" helped.
Thanks for the lead!
In the end, I also had to invoke the business component method SetAdminMode with "true" as the argument so that I could also modify the records from my script. -
External SOAP client Accessing Webservice using built in Java Data type
We have built a webservice and deployed it on WLS. We accessed this from a swing
client it works fine.The webservice methods uses non-built in JAVA data types
as parameters.These are Value Objects and the JAVA Serializer and Deserializer
classes are generated using Ant task itself.The client coding uses Value objects
given by the Client_jar (generated using <Clientgen> ant task) to pass to the
webservice. We dont want to go by this way.Is there anyway were in we can pass
parameters to the method which expects non-built in java datatypes?
Why i am asking this is, i want to know how an external client (.Net client )
will be able to exceute my webservice (i.e., passing the required Object which
the method is expecting)?Hi Anish,
Well first off, your web service doesn't send or receive "objects". It only sends
and recieves XML, which is in turn converted to/from Java objects at invocation
time. Second, a .NET (or Perl, or Python, or C++) client will be able to call
your web service, because the wsdl.exe tool (for .NET) will generate "programming
language specific" objects from the <types><schema> elements, in the WSDL of your
web service :-) The wsdl.exe tool will create C# objects from the WSDL, that will
convert XML to/from C# when your web service is called. That's the beauty of XML
schema - it's a "universal typing system", so it's not tied to a particular programming
language. The only issue is whether or not the web services platform vendor's
XML Schema/WSDL processor, can successfully process the WSDL. Some vendors have
more complete implementations of the WSDL and XML Schema specs than others, so
expect varying success here. The one in WLS 7.0 is pretty good, so you shouldn't
have too many problems consuming WSDL generated by .NET tools (or any other tool
for that matter).
Regards,
Mike Wooten
"Anish" <[email protected]> wrote:
>
We have built a webservice and deployed it on WLS. We accessed this from
a swing
client it works fine.The webservice methods uses non-built in JAVA data
types
as parameters.These are Value Objects and the JAVA Serializer and Deserializer
classes are generated using Ant task itself.The client coding uses Value
objects
given by the Client_jar (generated using <Clientgen> ant task) to pass
to the
webservice. We dont want to go by this way.Is there anyway were in we
can pass
parameters to the method which expects non-built in java datatypes?
Why i am asking this is, i want to know how an external client (.Net
client )
will be able to exceute my webservice (i.e., passing the required Object
which
the method is expecting)? -
Hi,
I am trying to get the difference between two sets of time.
This also involves a Date comparison because sometimes the times span more than one day.
Here is an example of what I'm trying to accomplish. I have searched the forum archives but have not yet found time and date comparisons together.
startRun = "10/26/01 4:30 PM";
endRun = "10/27/01 7:45PM";
I want to process these two times and get the difference.
The result would be:
totalRunTime = "27 hours 15 minutes";
I am stumped. Is this type of process even possible? Any help would be grealty appreciated.
Best,
Christian Velez
Senior Software Engineer
Research Institute of America, Inc.
[email protected]try this ...
String startRun = "10/26/01 4:30PM";
String endRun = "10/27/01 7:45PM";
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mma");
try {
Date startDate = sdf.parse(startRun);
Date endDate = sdf.parse(endRun);
System.out.println("Start date/time = " + startDate);
System.out.println("End date/time = " + endDate);
long differenceInMillis = endDate.getTime() - startDate.getTime();
long differenceInSecs = differenceInMillis / (1000);
long differenceInMins = differenceInMillis / (1000 * 60);
long differenceInHours = differenceInMillis / (1000 * 60 * 60);
System.out.println("Millis = " + differenceInMillis);
System.out.println("Seconds = " + differenceInSecs);
System.out.println("Minutes = " + differenceInMins);
System.out.println("Hours = " + differenceInHours);
//What you want
System.out.println("Total run time = "
+ differenceInHours + " hours "
+ (differenceInMins % 60) + " minutes");
} catch (ParseException pe) {
} -
OBIEE Date Comparison report with multiple measures
Hello everyone...
I have a requirement where I need to create a date comparison report (Current Month vs. Prior Month vs Prior Month Year Ago vs YTD vs Prior YTD vs Rolling 3 months, etc) with multiple Measures (Quote count, Quote offered count, New Business count, etc). I am to generate this report in this fashion:
Quotes Current Month vs PM vs YoY Prior
Month Current Month Prior Year Current
YTD vs PM Prior
YTD Rolling 3 Months vs PM Prior Rolling 3 Months
Issued 120 120 123 1400 1020 1700 1580
Unique Risks
Offered 556 449 571 5881 6220 6101 5892
Unique Risk Close Ratio
Offered Close Ratio 21.6% 26.7% 21.5% 23.8% 16.4% 27.9% 26.8%
Bitmap
Avg Issued Premium 240 238 222 2801 2630 3104 2892
Avg Offered Premium
New Business
Count
Avg Full Term Premium
I understand that time series is an option, and have created the time series (which show up as measures).
My problem is:
when creating the report (even as a pivot table) , OBIEE is not allowing me to drag the measure to rows, nor is it allowing me to drag the time series to columns. Also, I need to do conditional formating on some of the columns showing an up arrow for increased vs. prior month and down arrow for decreased vs. prior month.
Does anyone have a solution for this issue? Any assistance would be greatly appreciated...
Please advise and thanks!!!Jason,
You've been very helpful, but I guess I'm just not explaining myself that well. The Credit Memo's throw things off because they do not contain a "Paid Date" value. That field in the record is blank. Since it is blank the report query ignores them. Therefore when the report query returns all records that have a "Paid date" range of "x to y" they are never returned. This is a problem whenever a credit memo exists for an invoice because the "invoice total" never changes. So when a customer pays on their account for a particular invoice, they only pay what is due which is the "invoice total" minus any "credit" from the "Credit Memo". So when my A/R person receives payment they are showing the invoice paid in full because MAS automatically includes all invoices and credit memo's. My report does not because there is no data in the "Paid Date" field of the record for Credit Memos.
I've been doing alot research in trying to resolve this "exception" to my report. I think I may be on to something, but my knowledge of arrays is extremely limited. My resolution involves populating an array with the "invoice numbers" that are returned from the initial query from the supplied date range. Then using the "invoice numbers" from the array have it then populate my details section of the report with all of "invoice records" both the actual invoice record and any "credit memo" records. I can then group the records returned based upon the "invoice number". then within that grouping I can performing my calculations to show whether or not the invoice has been paid in full. What do you think? I've been able to populate an array with the invoice numbers based upon my date search range, but I have yet to figure out how to take that information and perform another lookup to pull in the rest of the data I need. Do you have any ideas?
Thanks. Bill -
From Time column in Excel to Java Date ?
Hi there!
After I have read range data from Excel to a Java Object[][]
array/table, one of my excel time columns becomes "floats"
numbers when I try to access them in Java, like this:
from 15:00:00 in Excel to 0.625 in my Java program
How can I avoid this OR transform/parse this 0.625 number
back again to time/Date 15:00:00 inside Java ? hmmm
Is there any setup of jCom that can controll this somehow ?
I have been able to transform:
from 11.15.01 in Excel, becomes "Thu Nov 15 00:00:00 CET 2001"
with the jCom bridge ...
When I have this "string" on this format, it's easy
to get a Java Date of this with SimpleDateFormat.
... but not with this time of mine :-)
Any clues where to look or a solution for this ?
-- Thank you !
-- ErlendExcel stores times as decimal fractions (representing portions of a day)
There is no Time data type in VB so is probably represented by a Single
object.
This object is then converting to a java.lang.float on the Java side.
0.625 can be parsed by multiplying by (24*60*60) to get the number
of seconds after midnight.
A list of supported COM data types and their java equivalents
can be found in chapter 7 of the jCOMReference pdf file.
damon
"Erlend Bjorge" <[email protected]> wrote in message
news:3be2983e$[email protected]..
>
Hi there!
After I have read range data from Excel to a Java Object[][]
array/table, one of my excel time columns becomes "floats"
numbers when I try to access them in Java, like this:
from 15:00:00 in Excel to 0.625 in my Java program
How can I avoid this OR transform/parse this 0.625 number
back again to time/Date 15:00:00 inside Java ? hmmm
Is there any setup of jCom that can controll this somehow ?
I have been able to transform:
from 11.15.01 in Excel, becomes "Thu Nov 15 00:00:00 CET 2001"
with the jCom bridge ...
When I have this "string" on this format, it's easy
to get a Java Date of this with SimpleDateFormat.
... but not with this time of mine :-)
Any clues where to look or a solution for this ?
-- Thank you !
-- Erlend -
Hello
In java Date, the months ranges from 0-11 . first january is thus 1/0/2003 (in dd/mm/yyyy form). But in almost all databases , month values are counted as 1-12 . That is first january becomes 1/1/2003 . Obviously we have to show the users month values from 1-12 and not from 0-11. This obviuosly places some overhead when doing calculations and display. Sometimes there are situations where we have to get the date from database using getString() function, but that will vary with the result of Resultset.getDate() . Any way to overcome such limitations? and why java has such dates?I kind of agree. When I first started, I felt that I shouldn't ever rely upon an assumption about the value of a constant field (i.e. Calendar.JANUARY, etc).
But since I did need to have a user-intuitive interface (both in guis and because we deal regularly with processing today's or yesterday's version of a file named like yyyyMMdd.input), I always provided a class that was a day-only object who did its behind-the-scenes work with Calendar by using switch statements to choose the correct Calendar month constants (rather than by adding or subtracting one).
But (a) that got old quick because of either the same cumbersome code repeated everywhere or having to have many otherwise simple standalone programs depend on a central utility class to do this, and (b) the Calendar class documentation states that the value of the month is zero-based, so the horror of assuming constant values is not so bad.
So now I have slightly less cumbersome code (adding or subtracting one) repeated everywhere... -
How to execute Custom java data source LOV view object from a common mthd?
Hi,
My application contains Custom java data source implemented LOVs. I want to have a util method which gets the view accessor name, find the view accessor and execute it. But i couldn't find any API to get the view accessors by passing the name.
Can anyone help me iin how best view accessors can be accessed in common but no by creating ViewRowImpl class (By every developer) and by accessing the RowSet getters?
Thanks in advance.I am sorrry, let me tell my requirement clearly.
My application is not data base driven. Data transaction happens using tuxedo server.
We have entity driven VOs as well as programmatic VOs. Both are custom java data source implemented. Entity driven VOs will participate in transactions whereas programmatic VOs are used as List view object to show List of values.
Custom java datasource implementation in BaseService Viewobject Impl class looks like
private boolean callService = false;
private List serviceCallInputParams = null;
public BaseServiceViewObjectImpl()
super();
* Overridden for custom java data source support.
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams)
List dataFromService = null;
if(callService)
callService = retrieveDataFromService(serviceCallInputParams);
setUserDataForCollection(qc, dataFromService != null? dataFromService.iterator(): null);
super.executeQueryForCollection(qc, params, noUserParams);
* Overridden for custom java data source support.
protected boolean hasNextForCollection(Object qc)
Iterator<BaseDatum> datumItr = (Iterator<BaseDatum>) getUserDataForCollection(qc);
if (datumItr != null && datumItr.hasNext())
return true;
callService = false;
serviceCallInputParams = null;
setFetchCompleteForCollection(qc, true);
return false;
}Individual screen developer, who want to load data to VO, will do something like the below code in their VO impl class
public void fetch()
BaseServiceViewObjectImpl vo = this;
vo.setCallService(true);
vo.setServiceCallInputParams(new ArrayList());
vo.executeQuery();
}As these custom java data source implemented LOV VOs comes across the screens, i want to have a util method at Base VOImpl class, that gets the view accessor name, finds the LOV VO instance, retrieves data for that. I want to do something like
* Wrapper method available at Base Service ViewObject impl class
public void fetchLOVData(String viewAccessorName, List serviewInputParams)
// find the LOV View object instance
BaseServiceViewObjectImpl lovViewObject = (BaseServiceViewObjectImpl) findViewAccessor(viewAccessorName);
// Get data for LOV view object from service
lovViewObject.setCallService(true);
lovViewObject.setServiceCallInputParams(serviewInputParams);
lovViewObject.executeQuery();
Question:
1. Is it achievable?
1. Is there any API available at View Object Impl class level, that gets the view accessor name and returns the exact LOV view object instance? If not, how can i achieve it? -
Question on How to Use LI and NP Data Comparison Report
Hi,
We are trying to figure out how to make the Transaction Code PC00_M42_LLPD (LI and NP Data Comparison Report) work. What file type (.xls, .txt, etc) should be used? Anyone who is familiar with the transaction, please help.
Best Regards,
BrySomewhere in the Oracle 8.0 documentation it is stated that one
enviroment per each thread is required if I want to ensure
complete concurrency of different threads accessing databases.
But isn't this a waste of resources since only Handle Alloc &
Free functions use Enviroment handle, hence they should be
mutexed for access from concurrent threads.
But the most time-consuming functions are ServerAttach &
SessionBegin which shouldn't be mutexed since they have each
their own Server/Session handle.
So my question is if a single OCI Enviroment is enough for the
most demanding tasks or should I create one enviroment per
thread?
Most folks are happy with a single environment. The mutex on the
env handle is only taken when the OCI library is allocating some
memory for internal operations.
Tomislav. -
Customized java date function in heart of JDK
hi
how can i force JDK to return Persian or Arabic date instead of christian era?
i have an application in java platform. i couldn't change code of program, because source is closed and is not reachable. i want to know how can i use a wrapper for date function in java? if it is possible how can i replace java date functionality with my desired date function?
thanks for any helpThanks for your help.
however i looking for one thing, similar a function wrapper that can substitute original method.
I don't know where the application use date function and how calls it. so i think that it is possible to change behavior of java itself.
Maybe you are looking for
-
Observed on the steam marketplace (on activation some older tabs will load an item instead of what used to be a search query listing multiple items, page url changed and no back button available). For example: The tab url was http://steamcommunity.co
-
I ran a System Restore in my Windows XP notebook and now iTunes will not open. The message: The file "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes. What can I do about this?
-
URGENT: Journal Batch Workflow Issue
Hi All, I am facing issue with Journal Batch Workflow. There is function called "Find Approver",when we go for Approve the Journal then it returns "NO Approver Find".But when sysadmin reassign to requestor and requestor response as "Problem Fixed" th
-
File associations not roamed using Remote Desktop Server 2012 R2 Standard
Hello everyone, As the title mentions, some File Associations does not seems to roam on a RDS 2012 R2 server. We use the following configuration: Windows Server 2012 R2 Remote Desktop Server(s) Roaming Profiles to a user based network share Delete ca
-
How do i upgrade my 3gs to IOS6?
I do not see the option to upgrade to IOS 6. Where is the link?