Date conversion madness! String to date and vice versa
Hello, I am working on an application targeting the OS version 4.5.x. I read a lot of messages and the links on this topic and can't seem to make the correct code.
OK, here's the problem. I ask a timestamp date string to a server. The timestamp is the local time on the server (IS / PST etc.) and not GMT.
My application must take time and subtract a number of days ranging from 1 day to 1 month. to get a "start" date The application must then provide the start and end date in a string format that it understands. Seems simple isn't?
Here's the catch, however the time stamps should NOT be changed by the local what is using the device. For example, a device in Italy can contact the server located in Ottawa and ask a timestamp, the calculations shouldn't care about DST or time zone. Just take the supplied date and subtract a fixed number of days from her. Nothing more or less. This proved incredibly hard to do. first the HttpDateParser.parse (ServerTimeStamp) will be the subject of Date GMT and my problem is back to the zone specified in ServerTimeStamp.
Thanks for any help in advance.
My method
public String getDAFIXMLRange (String ServerTimeStamp) {}
String szRange;
First analyze the incoming date and record them at the time of the last election.
Day DAFIEndDate = new Date (HttpDateParser.parse (ServerTimeStamp));
m_lLastPollTime = DAFIEndDate.getTime ();
define the offset. Pre-programmed for simplification.
lOffsetNumberOfSeconds long = 2 * 24 * 60 * 60;
Calculate the start date by subtracting the offset. Multiply by 1000 to convert to milliseconds!
Date DAFIStartDate = new Date (DAFIEndDate.getTime () - (lOffsetNumberOfSeconds * 1000));
!!!!!!!!!!!!! HOW the DATEFORMAT OBJECT is used to get the output format ' yyyy-MM-dd' you HH: mm: "without the marker of time zone. The server knows that it is local to it. !!!!!!!!!!
Now format the objects date as a string that includes the XML server.
DateFormat DafiDateFormat = DateFormat.getInstance (); ' YYYY-MM-dd' you HH.
!!!!!!!!!!!!!! THIS IS THE PART I'M CONFUSED on, with the HELP of zone to create the good date. !!!
Time zone tz = TimeZone.getTimeZone ("IS");
int adjEST = tz.getRawOffset ();
Convert 'em in string format.
String szDAFIStart = DafiDateFormat.format (DAFIStartDate);
String szDAFIEnd = DafiDateFormat.format (DAFIEndDate);
Replace the date calculated in the end segment ranges date XML.
szRange = statItems.replaceAll (XML_DATERANGE, "TAGSTARTTIME", szDAFIStart);
szRange = statItems.replaceAll (szRange, "TAGENDTIME", szDAFIEnd);
Return szRange;
}
Hello
Yes would be better if the server could provide you date to the GMT time zone, or date as a long.
But if you can't ask the case on the server, one way might be to manually parse your string and create a new date of parameter values in a calendar, something like this
Calendar cal = Calendar.GetInstance ();
Cal.Set (Calendar.DAY_OF_MONTH, date)
Cal.Set (Calendar.MONTH, month-1)
Cal.Set (Calendar.YEAR, year);
' set the new time with the values, you must cal.setTime (cal.getTime ()-,...);
and then put the date with SimpleDateFormat.
I think that this could be a solution if you know the format string you recived that date and it won't change.
I'm not sure but maybe it could be a solution.
Kind regards
Tags: BlackBerry Developers
Similar Questions
-
Conversion table of Partition Non-Partition and vice versa
Hello
I followed the method of Partition to Partition and vice versa conversion table below. Please suggest is here
any other altrnative methods available to accomplish the same thing.
Conversion table of partition table partitions. Export data, drop the table, create the table with partitions and
import data into the same table, now, the data is organized with Partitions.
Conversion table of partition table non-partition. Export data, drop the table, create the table without partitions and
import data into the same table, now, the data are organized without Partitions.
Thank you.Google "oracle Exchange partition".
-
ASCII to EBCDIC Conversion and vice versa
Hello
I have a Service Proxy (any Service of XML), which I'm routing to a business (any Messaging Service) Service. I use JMS to business protocols. In the business service, I want to put the request for a RequestQueue (who needs data to be EBCDIC) and pick up the answer to a ResponseQueue (which contains the data of the EBCDIC).
Please help me how to convert the XML to ASCII to EBCDIC (CP037) and vice versa.
Thanks in advance!
Kind regards
KKI've never tried, but I think you can write a MFL using Format generator for this conversion. Please see-
http://download.Oracle.com/docs/HTML/E15866_01/part_fb.htm#BABEAIAF
EBCDIC Data ConversionKind regards
Anuj -
read and write (control should serve as an indicator and vice versa)
Control (Input) should act as indicator (output) and vice versa for a transmission.is of the string, it is possible
-
I have windows vista business edition is installed on the desktop and Vista home edition on my laptop I can't access files on the laptop and vice versa, I am using a d-link adsl router can u help me solve problems
Thank you
PeterHello
The easiest way is with a crossover cable - a special wire to connect the two systems.
You can get one at your local computer store - they are not expensive.Also check with the site of the manufacturer of your router, because they will have in-depth details on how to
set up the network.====================================
Or you can set up a wired or wireless network.
Setting up a network home
http://Windows.Microsoft.com/en-us/Windows-Vista/setting-up-a-home-networkHome network, wireless network and computer networking Made Easy
http://www.home-network-help.com/Windows Vista tip: How to install and connect to a wireless network
http://www.watchingthenet.com/Windows-Vista-tip-how-to-Setup-and-connect-to-a-wireless-network.htmlAd-hoc networking
http://windowshelp.Microsoft.com/Windows/en-us/help/0e158c21-4C70-4235-879d-0c9133218e561033.mspx
Set up a computer-to-computer (ad hoc) network
http://windowshelp.Microsoft.com/Windows/en-us/help/293c504f-b944-4d5d-835c-f080129bd5dc1033.mspxHow to set up an Ad Hoc wireless network in Windows Vista
http://www.home-network-help.com/ad-hoc-wireless.htmlCreate an ad hoc WiFi network secure on Windows Vista
http://www.Intel.com/support/wireless/WLAN/sb/CS-025386.htmNetworking tutorial home
http://www.tehnomagazin.com/computer/home-networking-tutorial.htm
Practically networked - everything you could possibly want to know.
http://www.practicallynetworked.com/I hope this helps.
Rob - bicycle - Mark Twain said it is good. -
Is it possible for my tags in Windows to reflect also on Mac and vice versa?
Hello! I recently bought a MacBook and a new hard drive. I'm organizing my files on my Windows desktop. I already started to organize into folders, adding tags and authors and all that. But when I checked on my Mac, the metadeta was not there and vice versa. Please, I really need help. I search online and could not find a solution.
Maybe this will help > http://thefamilycurator.com/moving-photo-metadata-between-windows-and-mac/
-
A LabVIEW vi or llb developed on a Mac runs on windows and vice versa
Does a vi in LabVIEW/llb developed on Mac OS work on Windows and vice versa. ?
For the most part, Yes. If there is no specific code either Mac or Windows (such as the ActiveX calls), so the code will not work.
-
my keyboard gives sign 'inverted commas' for the 'at' key and vice versa. How can I fix it?
[Moved from comments]
Wednesday, November 7, 2012 16:07:16 + 0000, jimYK wrote:
my keyboard gives sign 'inverted commas' for the 'at' key and vice versa. How can I fix it?
Go to control panel | Regional and Language Options. Keyboards and
Translation? You put it in a language that does not correspond to the
physical keyboard.Ken Blake, Microsoft MVP
-
"Labtop keys two-way when want it @ key IAppuyez the" and vice versa
"When I want the @ key IAppuyez the" and vice versa
-
It takes up to 4 minutes for the player switch between library and Rip, and vice versa.
I run Media Player 11 on my XP machine with spare 120G on the C: memory and 3G - recently, it takes up to 4 minutes for the player switch between library and Rip, and vice versa. I have re-installed twice but no change. No new software has been installed before this time.
Hello Absno69,
Thank you for your message. You mentioned that there were no new software installed before that happens. Were there any hardware changes or updates? If this isn't the case, we will perform a system restore to a point that you know that your system is working effectively. Click HERE for the system restore instructions.Please let us know if it did or did not help to solve your problem.See you soonEngineer Jason Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.
-
How do I set in order to access my att LG android w\kitkat and my laptop w\8.1 and vice versa.
Thank you. Roy
Hello Roy,
- You try to synchronize the content between the phone LG Android with the PC?
- What the model number of the LG Android phone?
To connect the LG Android with PC phone check the links provided below.
http://www.LG.com/ca_en/support/PC-Suite
http://www.LG.com/ca_en/support/mobile-support
Let us know the State of the question and we will be happy to help you.
-
Bin icon diseappear when changing my computer icon and vice versa
Problem: When I change the icon of my computer icon changes, but bin icon diseappears and vice versa. Funny thing - in the folder "Desktop" icon all still exist with the new image.
Help, what do I do that two icons visible not only in the "Desktop" folder, but also real desktop?
Hi SigdisWotansson,
See if clearing the cache of the help icon.
How do I rebuild the icon Cache in Windows Vista and Windows 7
http://www.Winhelponline.com/blog/how-to-rebuild-the-icon-cache-in-Windows-Vista/ -
Change of Smartphones blackBerry quickly to vibrate and Vice Versa?
When you go to a meeting or somewhere else, "quiet", is there a way to shortcut quick and easy to change ring to vibrate without going deep into the profile to change the settings? And vice versa the meeting rapidly changing of the last ringtone vibrate? Sorry for all the questions; I love this community! Just found today! Thank you!! PeteRizz
Straight to the vibration mode is not possible. However, if dial all the home screen is disabled, then pressing P on the sleep mode you brings to the profile menu. Now select the vibration mode... no sense reverse!
-
Original title: messed up keyboard
HI friends, I don't know why, but my keyboard is messed up. When I type and I press shift + 2 it appears "and vice versa. How to solve this problem. I have recently installed Windows 8 company built N 9200 & the problem occurred when I had to connect to my Live account. Its really messed up, not only these but also other keys, & I am facing problem to type anything.
In this case, I'll try this.
- Right click your Start button (bottom left) and choose Control Panel
- In the search box, type "keyboard".
- At the bottom of the search results, choose "change input methods.
- Make sure that "English (United States)" is selected for the configuration of the keyboard
-
ProBook 4530 s: sometimes when I type @ it my computer types "and vice versa.
When I type the symbol @, he types sometimes ".» If I type ', it appears as @.»
Hello
This is usually due to the incorrect set keyboard layout - IE a U.S. keyboard with UK put in play, and vice versa. You can check if the correct layout is defined as shown in the following document from Microsoft.
http://Windows.Microsoft.com/en-GB/Windows/change-keyboard-layout#1TC=Windows-7
Kind regards
DP - K
Maybe you are looking for
-
I can't put my keyboard clicking sound
I have an iphone 16 G 5s with iOS 9.2.1 on that system. I always kept keyboard clicks and all of a sudden, they started clicking so I checked my settings, noticed that they were still closed, and I turn them on and turns off a few times only to find
-
Failed: Intel management engine Firmware Recovery Agent
My new Y50 automatically runs a program called "Recovery Firmware Intel Management Agent" engine. This software checks the updates of drivers/firmware. HOWEVER on my machine updates verification FAILS. The error message is: 'we're sorry, but the upda
-
I start to download el captain, he paused now, how can I cancel
I started to download el captain, he paused now, I have to cancel the download, memory goes to 99%, the system is very very slow, how can I cancel the download every 5 minutes I hv to restart the mac
-
Contacted by "telephone identifying himself as Windows REP and I had more than 100 errors on my files. It was a random contact and said his name was "Vincent. The statement coincided with the same "pop up" message that appears when ever I gwent in m
-
Clients vpn AnyConnect and cisco using the same certificate
Can use the same certificate on the ASA client Anyconnect and cisco vpn ikev1-2?