I am using Calendar class, and want to see if a date is older then 24 hours
i have a Calendar class instance, and i want to test if the current date & time is older then 24 hours. i have been playing with for 2 hours. anyone know how to do this?
One way is to call .getTime().getTime() (yes, that's 2 of 'em) on the Calendar object, which converts the Calendar's time to a milliseconds value which can be compared to System.currentTimeMillis()
The two times are within 24 h of each other if the ms values differ by less than 86 400 000.
Similar Messages
-
Using Calendar class and time stamp
I am trying to generate a timestamp for posted messages using the following code:
Calendar cal = Calendar.getInstance();
int m = cal.get(Calendar.MONTH);
String dd = new String().valueOf(cal.get(Calendar.DAY_OF_MONTH));
String yy = new String().valueOf(cal.get(Calendar.YEAR));
String hh = new String().valueOf(cal.get(Calendar.HOUR));
String min = new String().valueOf(cal.get(Calendar.MINUTE));
String sec = new String().valueOf(cal.get(Calendar.SECOND));
String time = hh+":"+min+":"+sec;
However, it seem that when there's a time such as 12:02:08, the actual variable time is as follows: 12:2:8 because the leading zeros are removed? I wouldn't think using it as a String would cause that but I suppose it could be my data types. OR is there an easy way to correct this?
thanks in advance,
ChuckYou could try:
String hh = (cal.get(Calendar.HOUR) < 10) ? "0" + new String().valueOf(cal.get(Calendar.HOUR)) : new String().valueOf(cal.get(Calendar.HOUR));
As Dr Clap already said, you should probably use SimpleDateFormat. I'm sure you can use it to generate whatever formats you need for your unique filenames. -
Can someone please suggest a backup storage unit that would go well with a MacBook?
Pretty much an well-known USB or Firewire external drive. If you want bootable clones, Western Digital hard-drives are known to have occasional problems.
-
Hi all,
can anybody help me for developing a program using Calendar class.what i am trying to do is
I have javascript calendar file. daily working hours in perticular project (user give input).
when i am selecting whole week days can i get total of weekly working hours and total in the next page or same page.
please help me. I am strucking here
thanks®ards
VijayaDo you want a Java program, or a JavaScript program. Java != JavaScript
-
Hi when i use treeMap class and if i exit the program
hi
hi when i use treeMap class and if i exit the program,
what will happen? the information that i put in the treeMap will be disappear??
if it is like that,,how am i able to retrieve my data...when i restart my program..
once i put ID as key and put my customer information,
in it, after exit my program,, and i can't find
my customers by their ID,,,,,,,,,how can,,i solve it......what will happen? the information that i put in the
treeMap will be disappear??Yes. Of course. If you want data to hang around you have to tell the computer. If you want anything to happen you have to tell the computer.
if it is like that,,how am i able to retrieve my
data...when i restart my program..Tada! Tell the computer. Your simplest option is to use Serialization.
Before exiting your program, serialize your TreeMap to disk. After starting your program serialize your TreeMap from disk.
First stop should be your text book to learn what Serialization is and how it works, then try to write some code, then ask us to help with any problems.
Dave. -
ALV using ABAP Classes and Objects
Hi All,
I am trying to print the values in my internal table using ALV, using ABAP classes and objects. Here the title for columns are picked based on the title specified in the data element. I want to set the title of my columns by my own. how to achieve this ?. Please provide me a sample code if possible.
thanks & regards,
Navneeth.KHello Navneeth
The following sample report shows how to build and modify a fieldcatalog (routine <b>BUILD_FIELDCATALOG_KNB1</b>).
*& Report ZUS_SDN_ALVGRID_EVENTS
REPORT zus_sdn_alvgrid_events.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.
* SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
* NOTE: no parameter id available, yet simply show the priciple
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
* do nothing
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' ).
ls_fcat-hotspot = abap_true.
ls_fcat-scrtext_s = '<short text>'. " short text of column
ls_fcat-scrtext_m = '<medium text>'. " medium text of column
ls_fcat-scrtext_l = '<long text>'. " longtext text of column
ls_fcat-tooltip = '...'. " ALV control: Tool tip for column header
ls_fcat-coltext = '...'. " ALV control: Column heading
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Customizing FD01 and FB70 using PS Class and Characteristics
Hello SAP Experts
I have the following issue:
My client has a requirement where we need to customize the Customer Master (FD01) screen and the Invoice Posting Screen (FB70). A few additional fields have to be added by creating a separate tab. I was intending to take Abaper's help and do this using user exits but I have been suggested by the cleint to use SAP PS Class and Characteristics feature to do this. Can someone please throw some light on this feature and how can i create custom fields on FD01 and FB70 screens. Is there a way we could customize these screens using PS class and characteristics. Your opinions would be much appreciated.
Please kindly give your suggestions. Thanks in advance
Regards,
NikJoao Paulo,
Thank you for the response. I have tried to obtain some info from OSS but no luck. Tried all means but there is limited information available.
Nik -
I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.
Hi Frank ,
Please refer to the following link and see if this helps.
https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
Regards
Sukrit Dhingra -
can someone tell me how many seconds the cross fade is when running your Ipod 6th Gen nano in that mode? I teach spin class and want to know how much time I'm losing in that mode.
You aren't losing any time in that mode, but I believe it is a 10 second fade out/fade in.
-
How to upload using upload button and want to process it....
Hi,
I need a program to upload a file [Excel file] using upload button and
want to process the excel sheet and store the data in database.
I know that we can upload using Html - file type.
but I dont know how to retrieve that uploaded file to process it?
I mean , Is there any function like requset.getParameter() to get the uploaded file?Go to the [Apache Commons FileUpload homepage|http://commons.apache.org/fileupload] and carefully read the 'User Guide' and 'Frequently Asked Questions' sections from top to bottom (do not only focus on the code examples, but also on the article's text!!).
-
I use "element 12" and want like in the old PS version due Automating and Contact II upload multiple filesand print them with any columns and rows on the same page . How does it work?
Can you supply a link?
-
I purchased a used macbook pro and want to set it back to original factory settings
I purchased a used macbook pro and want to set it back to original setting
What to do before selling or giving away your Mac
Clean Install of Snow Leopard
1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
with your computer. Insert the disc into the optical drive and restart the computer.
After the chime press and hold down the "C" key. Release the key when you see
a small spinning gear appear below the dark gray Apple logo.
2. After the installer loads select your language and click on the Continue
button. When the menu bar appears select Disk Utility from the Utilities menu.
After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
size.) Click on the Partition tab in the DU main window. Set the number of
partitions to one (1) from the Partitions drop down menu, click on Options button
and select GUID, click on OK, then set the format type to MacOS Extended
(Journaled, if supported), then click on the Apply button.
3. When the formatting has completed quit DU and return to the installer. Proceed
with the OS X installation and follow the directions included with the installer.
4. When the installation has completed your computer will Restart into the Setup
Assistant. Be sure you configure your initial admin account with the exact same
username and password that you used on your old drive. After you finish Setup
Assistant will complete the installation after which you will be running a fresh
install of OS X. You can now begin the update process by opening Software
Update and installing all recommended updates to bring your installation current.
Download and install Mac OS X 10.6.8 Update Combo v1.1. -
HT201376 just got a used macbook pro and want to restore to facory settings how do i do is
I just got a used macbook pro and want to restore to factory settings....how do i do this safely?
Click here and follow the instructions. If the computer originally shipped with Mac OS X 10.6.8 or earlier, when you reach step 5, insert its original disk, restart with the C or Option key held down, use the Disk Utility to erase the internal drive, and install a fresh OS.
(118569) -
I have a new macbook air, and want to transfer all my data using time machine from my old macbook running leopard, is this possible and easy and will it transfer all my musc and photos?
The Setup Assistant can restore your data from a Time Machine backup. You'll be asked if you want to do this the first time you turn the computer on.
(60797) -
I have a G5 to sell and want to erase all my data from it, but the cd drive won't work so I can't use the OS10 start up disk. Any way to do it?
Do you have another Mac? If so, you can startup this one in "Target Disk Mode" (instructions here) and connect it to another Mac to delete the home folders (or the entire drive, if that's what you want).
One piece of advise, though: after deleting the data, and of course emptying the Trash, it wouldn't hurt to also securely erase the "free space" of the drive (instructions here) before disconnecting the old Mac from the new one. This can be helpful, since "deleted" data is often retrievable with ease unles it's written over after the deletion.
Maybe you are looking for
-
Can not transfer WMA audio books to new iPhone 4S
I got a new 4S and went to sync it in iTunes and got a message saying I had to load the latest version of iTunes and went ahead and did it and it worked fine. No issues and all synced and got all of my apps music and pictures!! Then i went to trans
-
Hi I am sending a fax using rfax but i can not understand how can i set the size of page. I am using html format to send data. please help me if anybody has knowledge of rfax.
-
IPAD4 w/skype no video possible fix
If you have skype on your IPhone or IPad make sure the person you are calling has accepted your skype address I had this problem but, when I was accepted the address the IPAD worked fine That is I could hear and see the other party Hope this will hel
-
6.1.2 update and "no service"
I've always struggled with "no service" on iPhones but since I got my iPhone 5 it's been near perfect, always had signal even in places I couldn't normally get a signal - that is, until I updated to 6.1.2. I'm kicking myself and am so frustrated. Sin
-
How to download extra content in GarageBand '11?
Hey, After clean installation of ML i'd like to download additional instrument for GB '11. When I'm pressing grey arrow in GB it takes me to the MAS update tab and said: "No updates available". I installed GB from iLife '11 DVD.