How to build a String from Date?
How to build a String from class Date?
How to get the year, month, day, hour ... from a Date object.
Ok to build a string use this function in java.util.Date
toString()
TO get year, date, etc u can use the following functions
getYear()
getDate()
This link might help u more
http://java.sun.com/products/jdk/1.1/docs/api/java.util.Date.html
Similar Messages
-
How to convert a string from upper case to lower case in FOX formula
Hi Experts,
How to convert a string from upper case to lower case in FOX formula?
Thanks,
Cheers!!!
PANKAJThe last result.append( c ) should be:
result.append( Character.toLowerCase(c) ); -
How to convert a string from lower case to upper case withour using transla
Hi all,
how to convert a string from lower case to upper case withour using translate,
Thanks in Advance,
ReddyRefer to this related thread
Re: hi guys this very urgent please help -
How to transfer a string from sub sequence to main sequence
Hi,
How to transfer a string from sub sequence to main sequence, My main sequence has included a sub sequence, the sub sequence is return a string value after running done, I need to get this string value from sub sequence to main sequence, I check the defined that look like seem the two
sequence have themself local variable,but I don't know how to defined a globe variable to cover main sequence and sub sequence like VC++'s Main App ,Please kindly help me,thanks in advance...Hi,
I hope this small example will help you.
Regards
Ray Farmer
Regards
Ray Farmer
Attachments:
Sequence File1.seq 36 KB -
How to read a string from file & assign the val to a variable in batch file
Hi,
How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
Any suggestions?
thanks.Unless this is a homework question then I don't see the purpose of doing this, but....
You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
Andre -
How to search a string from the database?
how to search a string from the database? starting with some character
If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
Here's an Example
SELECT obj_name FROM tadir
INTO prog
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name LIKE 'Z%'.
In this case it will select every row that obj_name starts with Z.
If you wanted to find every row that the field obj_name contains say... 'WIN' you use LIKE '%WIN%'.
Edited by: Paul Chapman on Apr 22, 2008 12:32 PM -
My coworker build a DLL from LabVIEW that I am trying to call from C++.
void__cdeclMeasureDCvolts(uintptr_t*VISAResourceName, int32_tChannelNumber,LVBoolean*MonitorResult,double*MeasuredVoltage, TD1*errorOut);
Does "extcode.h" define macros or functions for string conversions? Or should I request my coworker rebuild the VI's to make arguments more C/C++ friendly?
Thanks in advance for any tips or direction. Examples are * much * appreciated.
-Ed
TestObjectMeasurement* testObjectMeasurement = m_measurementMap[name];
TestObjectInstrument* testObjectInstrument = m_instrumentMap[selectedInstrumentName];
int slot = 1;
int bank = 1;
int channel = 1;
int channelNumber = 1000 * slot + channel;
char * visaResourceName = testObjectInstrument->visaResourceName().toLatin1().data();
LVBoolean monitorResult = LVBooleanFalse;
double measuredVoltage = -1.0;
TD1 errorOut = {0};
try
// void __cdecl MeasureDCvolts(uintptr_t *VISAResourceName,
// int32_t ChannelNumber, LVBoolean *MonitorResult, double *MeasuredVoltage,
// TD1 *errorOut);
MeasureDCvolts(reinterpret_cast<uintptr_t*>(visaResourceName), channelNumber, &monitorResult, &measuredVoltage, &errorOut);
catch(...)
qDebug() << "Exception thrown by: MeasureDCvolts";
QString errorSource = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorOut.source)), LHStrLen(errorOut.source));
qDebug() << errorSource;
LStrHandle errorTextHandle = {0};
bool foundErrorText = NIGetOneErrorCode(errorOut.code, &errorTextHandle);
if(foundErrorText)
QString errorText = QString::fromUtf8(reinterpret_cast<const char*>(LHStrBuf(errorTextHandle)), LHStrLen(errorTextHandle));
MessageHelper::messageError(errorText, errorSource);Why is it not a solution? It was exactly about what you wanted to do and the solution in the last post is how it can be made to work. There is NO way to ddirectly create a LabVIEW native VISA resource in C code that is not called from within LabVIEW, unless you consider hacking the LabVIEW system and using undocumented functions a solution. But that has very good chances of breaking with future LabVIEW versions.
Your only other option is to export another function from the DLL that accepts a String and uses VISA Open to explicitedly open the VISA session in your LabVIEW DLL and returning that VISA session to your C code. This is functionally equivalent to passing a String to your current function but avoids the lookup and potential recreation of the VISA refnum on each call. Something I would only feel bothered if you intend to call this function many thousend times each second, which for VISA communication seems very unlikely.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How to assign to String[] from StringBuffer in a loop?
Hi all,
public class Test {
public String[] getSJ()
String[] jg;
String[] jig;
String[] tg;
String[] result;
Date startTime;
StringBuffer buf = new StringBuffer();
int i;
int j;
int k = -1;
jg = {"g1", "g2"};
for( i=0; i < jg.length; i++ )
jig = {"1", "2", "3"};
for( j=0; i < jig.length; j++, k++ )
buf.append( jg[i] ).append( ":" );
buf.append( jig[j] ).append( ":" );
buf.append( Date() );
result[k] = buf.toString();
buf = null;
}I want to add to result string array by assigning from buf which is StringBuffer in a loop. But what happens after buf = null??
Will the added String be gone?
Or should I just do:
buf = "";
and continue with the loop and the string objects will be preserved? But isn't result just an array of references?
Many thanks,I am not sure I understand correctly. Here is a test program (in real program I call APIs from a library which returns String[] for jg and for jig, i.e they are changing in the loop in runtime.
I tried to put together test program:
import java.util.*;
public class Test {
public void Test() {
public String[] getSJ()
String[] jg = {"g1", "g2"};
String[] jig = {"1", "2", "3"};
String[] result = new String[50];
StringBuffer buf = new StringBuffer();
int i;
int j;
int k = 0;
for( i=0; i < jg.length; i++ )
for( j=0; i < jig.length; j++, k++ )
buf.append( jg[i] )
.append( ":" )
.append( jig[j] )
.append( ":" )
.append( new Date() );
result[k] = buf.toString();
buf = null;
return result;
public static void main( String[] args ) {
Test t = new Test();
String[] res = t.getSJ();
for( int i=0; i<res.length; i++ ) {
System.out.println( res[i] );
}but when I run it fails in this statement:
buf.append( jg[i] )
.append( ":" )
.append( jig[j] )
.append( ":" )
.append( new Date() );Exception in thread main
java.lang.NullPointerException
java.lang.String[] Test.getSJ()
Test.java:24
void Test.main(java.lang.String[])
Test.java:38
Wierd!?
And if I change to:
buf.setLength(0);
then it fails with this error:
Exception in thread main
java.lang.ArrayIndexOutOfBoundsException: 3
java.lang.String[] Test.getSJ()
Test.java:24
void Test.main(java.lang.String[])
Test.java:38Also, I would like not to have to allocate like in:
String[] result = new String[50];
because I do not know how many different Strings in array will be returned by API. Is it possible to dynamically adjust
String[] result
somehow?
Many thanks, -
How to generate .txt file from data in internal table
Hi I am using the program below to load .txt file into SAP table.
I am moving the records from a .txt file into internal table final and then into ZOUT_CCFOBS table.
How do I load records from internal table final back to another .txt file with the same layout? Pls advice.
REPORT ZOUP_LOAD_CCF_OBS.
TABLES: ZOUT_CCFOBS.
TYPES: BEGIN OF tline, "structure to store a line of each row
line(1000) TYPE c,
END OF tline.
TYPES: BEGIN OF i_split, "structure to store split record of each row
t_ZOTFACIL(100) TYPE c,
t_ZOTCCF(8) TYPE c,
t_ZOTOBSCAT(100) TYPE c,
END OF i_split.
DATA: itab TYPE TABLE OF tline WITH HEADER LINE.
DATA: idat TYPE TABLE OF i_split WITH HEADER LINE.
DATA: final TYPE STANDARD TABLE OF ZOUT_CCFOBS WITH HEADER LINE.
DATA: file_str TYPE string.
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '.',
c_search_dir TYPE dxfields-longpath.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS p_file LIKE rlgrap-filename. "file location
SELECTION-SCREEN END OF BLOCK a1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_dxfilename USING p_file.
START-OF-SELECTION.
Download data from application server
PERFORM download_data.
file_str = p_file.
LOOP AT itab.
CLEAR idat.
this will split the line at every delimeter into single field
SPLIT itab-line AT ',' INTO idat-t_ZOTFACIL
idat-t_ZOTCCF
idat-t_ZOTOBSCAT.
APPEND idat.
ENDLOOP.
copying the internal table into final table which compatible with table tcurr
LOOP AT idat.
final-ZOTFACIL = idat-t_ZOTFACIL.
final-ZOTCCF = idat-t_ZOTCCF.
final-ZOTOBSCAT = idat-t_ZOTOBSCAT.
APPEND final.
ENDLOOP.
LOOP AT final.
MODIFY ZOUT_CCFOBS FROM final.
IF sy-subrc EQ 0.
MESSAGE S001(ZCURR).
ELSE.
MESSAGE A000(ZCURR).
ENDIF.
ENDLOOP.
FORM f4_dxfilename USING p_file.
addition TAICK 15/07/2008.
*maintain application server default search path.
IF sy-sysid = 'BWP'.
c_search_dir = '//rdmsbw/prd/data/output/all'.
ELSEIF sy-sysid = 'BWQ'.
c_search_dir = '//rdmsbw/uat/data/output/all'.
ELSEIF sy-sysid = 'BWD'.
IF sy-mandt = '900'.
c_search_dir = '//rdmsbw/sit/data/output/all'.
ELSE.
c_search_dir = '//rdmsbw/dev/data/output/all'.
ENDIF.
ENDIF.
DATA: wa_file LIKE dxfields-longpath.
CLEAR: wa_file.
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
i_server = ' '
i_path = c_search_dir
filemask = c_fnh_mask
fileoperation = 'R'
IMPORTING
o_path = wa_file
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
p_file = wa_file.
ENDIF.
addition end TAICK 15/07/2008.
ENDFORM. " f4_dxfilename
FORM download_data .
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
IF sy-subrc <> 0.
exit.
ENDIF.
READ DATASET p_file INTO itab.
if sy-subrc = 0.
APPEND itab.
clear itab.
endif.
ENDDO.
CLOSE DATASET p_file.
delete itab index 1. "remove column header
ENDFORM. " download_data
Edited by: RebekahMBB on Feb 20, 2012 12:56 PMHi I am using this piece of code to download my internal table into an .xls file on my pc.
FORM Z_CONVERT_EXCEL .
"This part of code to add column name in the downloaded file.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
int_head-Filed1 = 'ZOTOUS'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'ZOTOUS'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'ZOTOGCUR'.
APPEND int_head.
CLEAR int_head.
Select ZOTOUS ZOTSYORGU ZOTOGCUR from ZOUT_ORG_CURR into CORRESPONDING FIELDS OF TABLE itab.
v_filetype = '.xls'. "I just manipulate the file name using XLS file type.
v_filename = 'C:\Documents and Settings\00088592\Desktop\OUs automation\development'.
CONCATENATE v_filename v_filetype INTO lv_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = itab
FIELDNAMES = int_head
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. "Z_CONVERT_EXCEL
As you can see the code specifies the header row separately and appends it in int_head.
What if I have 76 fields or more? I cant be specifying each like that.
Is there any other way to do this? To move the 76 field headers into int_head?
Pls help.
Thanks! -
How to convert a string to date object?
I have a string user input for date.
I want to convert it to Date object to insert it in database.
How to do it?Check the java.text.SimpleDateFormat class. You can use it for parsing dates. API contains good description how to build the format pattern.
HTH
Mike -
How to create APEX report from data in PLSQL table
Hi, I have a procedure that is creating/inserting records into multidimensional pslql table. I want to create a report and graph based on the data stored in plsql table. Can someone please advice how to can I select this data in apex OR point me to any sample code?
Thanks
AaliHi,
try to google something about ORACLE TABLE CAST
SELECT ot.yourcolumn
FROM
TABLE(CAST(yourplsqltablevariable AS userdefinedoracletype)) otE.g.
http://it.toolbox.com/blogs/oracle-guide/using-a-plsql-table-in-sql-11013
Regards,
R. -
How to derive month/year from date in SAP BW 3.5 data flow
Hi
How we can derive cal year/month and fiscal month/year from date in SAP BW 3.5 data flow (we're using transfer and update rule)..
Thanks,
PKHi,
if you have any date filed in source side you can just map to any time char system will automatically convert to target objects.
please look at the screen shot for understanding. (not 3.x it is 7.x)
Thanks,
Phani. -
How to put a string from one Frame to another Frame?
Dear all,
How can I put a String from one Frame to another Frame?
When the application started, the Frame 'WindowX' will be displayed. After you press the 'openButton', a whole new Frame (inputFrame) will be shown. In this Frame )(inputFrame) you can write a String in a TextField. After pressing the okButton, this String will be sent to the first Frame 'WindowX'.
But does anyone know how to realize the sending part?
I've tested this code on Win98 SE and JDK1.2.2.
Hope someone can help me. Thanks in advance.
import java.awt.*;
import java.awt.event.*;
public class WindowX extends Frame implements ActionListener, WindowListener
private Button openButton;
private TextField resultField;
public static void main(String [] args)
WindowX wx = new WindowX();
wx.setSize(300,100);
wx.setVisible(true);
public WindowX()
setLayout(new FlowLayout());
openButton=new Button("open");
add(openButton);
openButton.addActionListener(this);
resultField=new TextField(10);
add(resultField);
resultField.addActionListener(this);
addWindowListener(this);
public void actionPerformed(ActionEvent evt)
if (evt.getSource()==openButton)
inputFrame ip=new inputFrame();
ip.setSize(200,80);
ip.show();
public void place(String theString) //this doesn't work
resultField.setText(theString);
public void windowClosing(WindowEvent event)
System.exit(0);
public void windowIconi......
class inputFrame extends Frame implements ActionListener,WindowListener
String theString = "";
Button okButton;
TextField inputField;
WindowX myWX=new WindowX(); //??
public inputFrame()
setLayout(new FlowLayout());
inputField=new TextField(10);
add(inputField);
inputField.addActionListener(this);
okButton=new Button("OK");
add(okButton);
okButton.addActionListener(this);
addWindowListener(this);
public static void main(String[] args)
Frame f = new Frame();
f.show();
public void actionPerformed(ActionEvent evt)
if (evt.getSource()==okButton)
theString=inputField.getText();
myWX.place(theString); //??
dispose();
public void windowClosing(WindowEvent e) {
dispose();
public void windowIconi......
}Thanks for your reply!
But I got an other problem:
I can't refer to the object (wx) made from the main Frame 'WindowX', because it's initialized in 'public static void main(String [] args)'...
Hope you can help me again... Thanks!
import java.awt.*;
import java.awt.event.*;
public class WindowX extends Frame implements ActionListener, WindowListener
private Button openButton;
private TextField resultField;
public static void main(String [] args)
WindowX wx = new WindowX(); //!!
wx.setSize(300,100);
wx.setVisible(true);
public WindowX()
setLayout(new FlowLayout());
openButton=new Button("open");
add(openButton);
openButton.addActionListener(this);
resultField=new TextField(10);
add(resultField);
resultField.addActionListener(this);
addWindowListener(this);
public void actionPerformed(ActionEvent evt)
if (evt.getSource()==openButton)
inputFrame ip=new inputFrame(wx);
ip.setSize(200,80);
ip.show();
public void place(String theString)
resultField.setText(theString);
public void windowClosing(WindowEvent event)
System.exit(0);
public void windowIconi....
class inputFrame extends Frame implements ActionListener,WindowListener
String theString = "";
Button okButton;
TextField inputField;
WindowX parent;
public inputFrame(WindowX parent)
setLayout(new FlowLayout());
this.parent=parent;
inputField=new TextField(10);
add(inputField);
inputField.addActionListener(this);
okButton=new Button("OK");
add(okButton);
okButton.addActionListener(this);
addWindowListener(this);
public static void main(String[] args)
Frame f = new Frame();
f.show();
public void actionPerformed(ActionEvent evt)
if (evt.getSource()==okButton)
theString=inputField.getText();
parent.place(theString);
dispose();
public void windowClosing(WindowEvent e) {
dispose();
public void windowIconi..........
} -
How can i pass string from C++ DLL to Java via JNI?
Hi everybody. I made a DLL with Borland C++. I must pass a string from this dll to Java via JNI.Namely i define a string variable in C++ DLL and i send this variable's value to Java via JNI.
I can pass integers but i couldnt Strings. . How can i do this? is there any sample?Hi,
So your function should be private static native String get_text();
(It's often a good idea to make native methods private since when you change signatures you generally have to change java wrapper methods only).
I know nothing about C++ strings but I'm pretty sure that you can convert it to char*, so
do :
char* szMyString = myString.toChar*();
Then return from native with JNU_NewStringPlatform(env, szMyString)
(see my 1st answer for JNU_NewStringPlatform() description).
--Marc (http://jnative.sf.net) -
How to create XML string from BPM Business Object?
Hello,
I have a business object in my BPM project and I need to transform it in a XML string:
From:
Business Object: Customer
Properties: Name, Age
To:
"<Customer><Name>Robert</Name><Age>17</Age></Customer>"
How can I do this?
Thanks.Hello,
I have a business object in my BPM project and I need to transform it in a XML string:
From:
Business Object: Customer
Properties: Name, Age
To:
"<Customer><Name>Robert</Name><Age>17</Age></Customer>"
How can I do this?
Thanks.
Maybe you are looking for
-
Ipad recognized by windows but not in itunes
When i connect my ipad to my windows 7 computer, only the computer recognizes the ipad. It does not show up in itunes. I have a different computer that does recognize it in itunes though.
-
Changing modes of volume / vibration / silent?
Hello guys! I have a problem with my z1, always when i tap my volume button down the phone goes to total silent mode, without vibration. I want it to vibrate even if I tap the volume all the way down. This is a problem because Im always just tapping
-
Hello I am not able to published to the web using an FTP the test has a negative response I do not know what is required in Directory/path Protocol and port
-
Transforming XML source to (X)HTML StreamResult outputs long comment
Hi, I'm using javax.xml.transform.* to transform XML data into an XHTML page. The XML data represents a document (contains information about headers, paragraphs, related pages, etc.) and an XSL file is used to properly transform that data into an XHT
-
An odd "kind" problem with some m4a files
I have 610 m4a files that iTunes thinks are mpeg-4 video files, while the Finder clearly shows that they're audio files. I only discovered this recently when I got my first video iPod, and went to sync my usual playlist of songs. In the first moments