Incrementing a string number for date and time
There are probably a lot of ways to do this, but I only want to use a bunch of if - else loops if I really need to.
I have a date and time for input, let's say 2006-04-19 22:00. In Java, if I convert that to 3 integers (year, month, day), it will output 2006-4-19. I need to be able to increment in a loop for every day and month from one date to the next. If I keep it as a string, I won't be able to increment the value though, (at least I'm not sure how). I'm thinking that even if I converted it to an integer and back to a string, that the leading zero would be removed.
I found a post here that said something about formatting the number with 2 numbers, by using:
DecimalFormat format = new DecimalFormat("00");
format.format(1, sb, new FieldPosition(0));
Or is there a way to use the gregorianCalendar stuff that would output the date with all of the zeros in place, while incrementing and looping correctly?
Thanks.
I would get a Date object--you can use java.text.SimpleDateFormat if you're starting with a String--and use that to create a GregorianCalendar. Then you can just call Calendar's add method to add one to whichever field you want. Use the SimpleDateFormat to turn the date back into a String for display again.
Calculating Java dates: Take the time to learn how to create and use dates
Working in Java time: Learn the basics of calculating elapsed time in Java
Formatting a Date Using a Custom Format
Parsing a Date Using a Custom Format
Similar Messages
-
Function Modules for Data and Time
Hi all,
I need 2 function modules for date and time. when we pass current data(sy-datum) and current time (sy-uzeit) into function modules, shoud get date in <b>dd/mm/yyyy or dd.mm.yyyy</b> and time in<b> HH:MM:SS</b> formats.
Thanks in advanceHi Ranjith,
i think this will b usefull for you..
SAP Bar Chart Function Modules and what they are used for
Function module
Used for
BARC_GRAPHIC_PBO
Starting bar chart at PBO time, using a graphic profile (parameter PROFILE)
BARC_GRAPHIC_PAI
Analyzing data returned by the graphic
BARC_SET_TIME_AXIS
Setting start and end of time axis
BARC_SET_OPTIONS
Setting options
BARC_ADD_CHART
Creating a chart
BARC_SET_CHART_ATTRIB
Setting chart attributes
BARC_ADD_SECTION
Creating a section on the time axis
BARC_SET_SECTION_ATTRIB
Setting section attributes
BARC_ADD_RIBBON
Adding a ribbon to the time axis
BARC_SET_RIBBON_ATTRIB
Setting attributes for ribbons in the chart
BARC_ADD_GRID
Adding a time grid
BARC_SET_GRID_ATTRIB
Setting grid attributes
BARC_ADD_LAYER
Adding a layer (graphic elements)
BARC_SET_LAYER_ATTRIB
Setting layer attributes
BARC_ADD_LINE
Adding a line
BARC_ADD_CALENDAR
Creating a calendar
BARC_SET_CALENDAR_ATTRIB
Setting attributes for a calendar
BARC_ADD_TIME_PROFILE
Creating time profiles
BARC_SET_TIME_PROFILE_ATTRIB
Setting attributes for time profile
BARC_ADD_INTERVAL
Adding a time interval
BARC_SET_INTERVAL_ATTRIB
Setting time interval attributes
BARC_ADD_TIME_OBJECT
Creating a time object
BARC_CONVERT_DATE
Creating a date string in bar chart format
BARC_REVERT_DATE
Converting a date string in bar chart format to date and time
BARC_ADD_DATELINE
Creating a date line
BARC_SET_DATELINE_ATTRIB
Setting dateline attributes
BARC_GET_PROFILE_CONTENTS
Obtaining profile contents for customizing a chart
BARC_GET_COLUMN_WIDTH
Selecting new column width
BARC_SET_COLUMN_WIDTH
Setting the column width
BARC_GET_TEXTINDEX
Obtaining the text index of a field
BARC_SET_LABELS
Positioning the chart display
BARC_SET_COLUMN_ATTRIB
Setting column attributes
BARC_SET_ROW_ATTRIB
Setting row attributes
BARC_SET_ROW_HEIGHT
Setting the line height
BARC_SET_MAXCHARTS
Setting the maximum number of charts sent
<b>If its usefull reward points
</b> -
To implement search help for date and time fields details
how can i implement search help for date and time fields in screen painter
Hi
Declare the variables as sy-datum and sy-uzeit or any other pre-defined data typ of date and ime types. Serach help will automatically comes.
Aditya -
My Apple TV froze while trying to access Netflix. I unplugged the Apple TV from the wall and re plugged it. Now it stays on the loading time and date setting. After 10 minutes, I held menu, and hit restart (as the troubleshoot said). Same problem is still occurring with the continuous "checking for date and time". And if I hold menu to bypass this, I only have my settings and computer icon, all other icons have disappeared. Not quite sure what to do, any comments would surely help.
Thanks guys, appreciate it.
MattApple TV 1st generation or 2nd?
I would try plugging in the HDMI from the ATV to a different HDMI port on your TV and even trying the ATV on a different TV altogether...sounds like the HDMI port on your TV might be bad or a bad connection. Keep in mind you'll need to switch the TV input to the new HDMI port -
Search Bill for Phone Number. Date and Times?
Hello-
I am having a problem doing a search over the past 12 months for an individual number.
Is there a quick and easy way to display the dates and times that I've placed a call to one specific number over the past 12 months?
Thank you!YPP wrote:
I was hoping for a way to search online and get a line by line display of dates for the calls made.
If I have to download each pdf into a spreadsheet, combine them and do a search it will take a considerable amount of time.
To reinforce Spiral's suggestion, if you go to the Usage Details tab you can download your data in csv format. Granted, downloading 12 files and stitching them together isn't as convenient as an online search. However, it's much easier to do this with csv downloads than it would be if you had to do the pdf-to-spreadsheet conversion yourself. And once you've pieced things together, the data are a lot of fun to play with. -
Hi All,
How I can find the date and time(log detail) - When the load of Attribute groups start and finish and when the Flex fields compiled.
Thanks,
SalUsing dataload, after loading some records application is crashing. Then we need to reduce speed. How I can avoid this issue.Are there any log files generated?
What could be the reason for this ( EBS issue or dataload issue).I cannot really tell since this could be related to EBS or Dataload.
Here we are using dataload classic.
Please help me on this.Did you see DataLoad user guide? -- http://www.dataload.com/help/support/gettingsupport.htm
You may also ask in DataLoad Forum -- http://www.dataload.com/forum
Thanks,
Hussein -
I've moved to Sweden from Canada, and when I plug my Apple TV in, I get the LED light and the Apple logo, followed by the Setting Date and Time message. After that, everything goes black and I can't make any selections. The LED lgiht is still on however.
Any help would be appreciated.Welcome to the Apple Community.
If your problem persists get yourself a micro USB cable (sold separately), you can restore your Apple TV from iTunes:
Remove ALL cables from Apple TV. (if you don't you will not see Apple TV in the iTunes Source list)
Connect the micro USB cable to the Apple TV and to your computer.
Reconnect the power cable (only for Apple TV 3)
Open iTunes.
Select your Apple TV in the Source list, and then click Restore. -
FM or BAPI for date and time for the creation of a Purchase Requisition
Hi people:
Does anybody knows about a FM, BAPI or table in which i have de detail for the date and hour of the creation of a Purchase requisition?
Points for helpfull answers.
Thanks in advancedHi,
If you want to get the time along with the creation date then use the tables CDHDR and CDPOS, but be careful while passing the data need to pass the entire primary fields data else it will fail in the performance test.
Reward points if useful.
Regards,
Suman -
SAP XI : Date and Time Service
Hi All,
Is there any runtime variable or service in SAP XI through which I can
map the current DATE and TIME of the system. Currently I am using XSLT mapping and
in that XSL I am calling java code for Date and Time.
So is there any other way through which I can Map the date in the output field
without calling Java code in XSLT.
Thanks
Farooqhi,
you can do it from java - if you use XSLT on java stack
you can do it from ABAP - if you use XSLT on ABAP stack
there are also java functions for date
in message mapping
so you can put two mappings (in your <b>interface mapping</b> object):
one XSLT
and one message mapping which will only fill the date
to see how many mappings work have a look at my weblog:
/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
Automatic file generation using system date and time
Hi guys,
Iam trying to generate a path for file creation automatically using System date and time. I am running into errors with respect to special characters in filename. I am trying to parse the string to get date and time without the '/' and ':' but have not been successful. is there a better way to do it? Please help! I am trying to avoid a dialog box for user to enter a filename.
Thanks!
V
I may not be perfect, but I'm all I got!
Solved!
Go to Solution.here is a little experiment .... building the path out of %m (month) %d (day) %(year) type stuff might help.
Attachments:
putting time in path.vi 7 KB -
To find the latest date and time
HI all,
I have a Ztable which contains execution date and exe time.
1) I need to find the latest date and time How can we do this?
2) In my program,I need to insert some values to date,time and status field in Ztable. How can I insert it directly into the table?
for eg ZTAB-DATE = 010122006
ZTAB-TIME = 12.20.20
just INSERT ZTAB is enough or NOT????????????
POINTS WILL BE REWARDED
THANKS IN ADVANCE1) You can do a number of things, one you can get all of the relevant records and sort the internal table by date and time in decending order, then simply read the first record of the internal table.
2) It depends on the key of the table. Say for example, you have a table like so.
MANDT
KEYFIELD
DATE
TIME
If the key alreays exists, you can use the modify statement to update the record, if it dosn't exists, you need to use the INSERT statement to insert the records.
data: xtab type ztable.
xtab-keyfield = 'ABC'.
xtab-date = '20070207'. " or sy-datum
xtab-time = '221600'. " or sy-uzeit.
insert ztable from xtab.
Make sure to use internal fomat for DATE and TIME.
Regards,
Rich Heilman -
How to display the current Date and time in xslt version 1
i am using xslt version 1 .i want to display the current date and time in the output xml using xslt(Jdeveloper) ..i just added the namespace xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:ns1="urn:oracle:integration:b2b:7D30046DC68A4FA689956D8241FA3B99">
and used thsi function <xsl:value-of select = "xp20:current-date()"/>
but it does not works for me ..help needed????
Edited by: user9519185 on Jan 20, 2009 3:04 AMUse a formula: =NOW()
Format the cell for Date and Time, with both the Date part and the Time part displayed. Format the two parts as you wish, using the choices in the Inspector's menus.
The cell will update each time the table is recalculated.
(Description is for Numbers '09 (Mac), Numbers for iOS will be similar, but not necessarly identical in details.)
Regards,
Barry -
Hi all
Would you mind tell me about that how to add
date and time in to GridBagLayout?
Thank you.Hi,
For Date and Time, look into java.util.Date or java.util.calender.
For displaying use a label, set text with the Date and time , add into the GridBagLayout.
Thats it..
Rajesh -
My new Nokia Lumia 800 changes date and time after...
When i switch off and on my Nokia Lumia 800, date and time changes: from 2 september 2012 8.00 to 2 march 2013 14.00. I need help to understand this strange problem and find a solution.
chrysale wrote:
I had the same problem with my Lumia 800. The Lumia 800 kept changing time and date as soon as I switched it off and turned it back on. In my case, doing a HARD RESET helped to fix this. BEWARE! You will lose all your data!
Switch off your phone, hold Volume Down, Power, Camera buttons down. Switch phone on. As soon as it vibrates, release Power button, keep Volume Down and Camera button pressed for a few seconds.
I have the same problem and after going through all the various support sites- Nokia, O2, and endless forums I was told the same thing "Make sure your auto-update for date and time is switched to automatic" But after telling them I don't know how many times that my Lumia 800 didn't have this option, only a 24 hours switch I was told there was nothing that could be done. However I appear to have sorted it out myself. The problem appears to be (or on my phone at least) is wi-fi connection, before I turn my phone off I have to disconnect from wi-fi and when I turn the phone back on the date and time stays corrected.
When I set the date and time manually (for the 3000th time!!) I held in the power button until the slide down close screen disappeared then released it and the phone restarts, then I done it again- same proceedure just to be sure and ever since the date and time has stayed correct. BUT BE SURE TO TURN OFF WI-FI BEFORE SWITCHING PHONE OFF. Hope this helps -
I've read that there are limitations with EJB QL queries when dealing with Date and Time objects. Specifically, Ive read that its recommended that longs (milliseconds) should be used in EJB QL queries instead of java.sql.Date and java.sql.Time. Ive also read that, in the where clause, the operators >= and <= cant be used when comparing date or time objects. Is this accurate?
If the first limitation is true, then does the date and time fields have to be represented as longs in the entity beans? and do the mapped columns (in the tables) have to be of numeric types for successfull synchronization?
When using longs for dates and times, can the >= and <= operators be used in the where clause?Hi ,
I am facing the same problem and my scenario is also same (BAPI's).
So can you please tell me how you overcome this problem .
Thanks,
Rahul
Maybe you are looking for
-
Could not initialize Photoshop because the file is locked
I have the problem where you get the Could not initialize Photoshop because the file is locked, where the solution was to fix the properties in the jpg. I did that and tried the Ctrl-Alt-Shft thing too. I pressed them in time and got the message to d
-
Hi, certain songs were not playing right on my 2009 iPod Classic, so I tried to do a restore on the iPod today, and re-sync all my music in iTunes to it. In the process of syncing all my music, the sync stalled, and now the device is not recognized i
-
Issues after Mountain Lion Update
Hello, can someone please assist me with this error report I receive after trying to open the desktop and screen saver in system preferences? I also cannot open finder, it does not respond at all and when I start the computer, it does not show user a
-
Need help for setFilterPredicate
Hello community, beeing quite new with the fascinating Xcode environment, I need your help for a simple thing of NSPredicate. ( Well, only simple for those who know...) I like to display a set of values in a tableview (tblView), and to filter it with
-
Zero timecode start for XDCAM EX files
After importing 1280x720 24p Sony XDCAM EX files, Project window displays zero starting timecode. I'm using the CS3 Education version, but it's the up-to-date 3.2.0. I have read that others have experienced this while others have not. No matter how I