I am using the following BlackBerry Java code for parsing the Date by setting its time zone too.
The Default timezone is +01:00 Europe/Belgrade Yugoslavia(YU)
I am using the following code :
Date formatter11 = new Date(HttpDateParser.parse("2013-08-02T14:00:00+04:00"));
Output comes as :
Fri Aug 02 12:00:00 Europe/Belgrade Yugoslavia(YU) 2013
which is wrong . Please let me know the error why parsing is not been correct.
It comes as one hour extra .
Actually , I was concerned for DayLight event that happens with Blackberry phones ... what is that issue .
Are you sure this is one hour extra?
The time seems to saying it is 14:00, and the time zone is UTC + 4 hours, So UTC time is 10:00, Yugoslavia is 1 hour ahead of that, plus daylight saving means 12:00.
Most likely I have missed something.
Related
Im trying to trasform a date to utc but moment return the same value i use.
for example
moment(date, 'YYYY-MM-DD HH:mm:ss').utc().format('YYYY-MM-DD HH:mm:ss')
if i use date = '2022-01-07 11:30:00' moment return 2022-01-07 11:30:00
do i have to set the timezone of the value first? why moment return the wrong value? it should return +3 hours that date.
You'll need to define the timezone in which the date is, then the offset will be as expected:
Example, using Europe/Amsterdam as timezone
const date = '2022-01-07 11:30:00';
const utc = moment(date, 'YYYY-MM-DD HH:mm:ss')
.tz('Europe/Amsterdam')
.utc()
.format('YYYY-MM-DD HH:mm:ss');
console.log(utc);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.32/moment-timezone-with-data.min.js"></script>
This will output 2022-01-07 10:30:00 since Amsterdam time is -1 compared to UTC.
Small side node, quoting MomentJS Project Status page
We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done.
In practice, this means:
We will not be adding new features or capabilities.
We will not be changing Moment's API to be immutable.
We will not be addressing tree shaking or bundle size issues.
We will not be making any major changes (no version 3).
We may choose to not fix bugs or behavioral quirks, especially if they are long-standing known issues.
The data you pass in doesn't have any indication of the timezone it's in, so moment is (I believe) assuming it's in utc already.
In related news, look into using the date-fns library instead of moment. Moment is getting old...
Moment github
Moment.js is a legacy project, now in maintenance mode. In most cases,
you should choose a different library.
This returns the same date since you never indicated any timezone
var time = moment("2013-08-26 16:55:00") //this creates time in my tz
You can set a timezone like this:
var time = moment("2013-08-26 16:55:00").tz("America/Los_Angeles");
I have created as Yahoo Calender link and it doesn't seem to be respecting the timezone for the end date:
https://calendar.yahoo.com/?v=60&TITLE=Chapter%20Luncheon%20-%20CO%20-&ST=20151022T170000Z&ET=20151022T190000Z&URL=tma.utdev.com&in_loc=Maggiano%27s%20Little%20Italy%20500%2016th%20St%20Ste%20150%20Pavilions%20Mall%2C%20Denver%2C%20CO%2080202%2C%20United%20States&desc=
This displays 1:00PM to 7:00PM. I am in the EST Timezone which is GMT-4:00, so 17:00:00 (aka 5:00) - 4 hours = 1:00 PM. But for the end time, 19:00:00 (7:00), its not converting and its leaving it at 7:00
For google it does work:
https://www.google.com/calendar/render?action=TEMPLATE&text=Chapter+Luncheon+-+CO+-&dates=20151022T170000Z/20151022T190000Z&sprop=website:tma.utdev.com&location=Maggiano%27s+Little+Italy+500+16th+St+Ste+150+Pavilions+Mall,+Denver,+CO+80202,+United+States&details&website=http://tma.utdev.com/event/chapter-luncheon-co&pli=1&sf=true&output=xml#eventpage_6
This displays the date 1:00PM to 3:00PM
From what I can tell, Yahoo Calendar doesn't support an ET parameter. (If it does, it's undocumented and buggy). I'd therefore recommend using the DUR parameter instead, to specify the duration:
https://calendar.yahoo.com/?v=60&TITLE=Chapter%20Luncheon%20-%20CO%20-&ST=20151022T170000Z&DUR=0200&URL=tma.utdev.com&in_loc=Maggiano%27s%20Little%20Italy%20500%2016th%20St%20Ste%20150%20Pavilions%20Mall%2C%20Denver%2C%20CO%2080202%2C%20United%20States&desc=
See http://chris.photobooks.com/tests/calendar/Notes.html or http://taskboy.com/blog/Creating_events_for_Yahoo_and_Google_calendars.html for more information on the supported parameters.
Apologies in advance. Due to the popularity of this library I'm sure the answer is out there but I haven't been able to find it.
I'm getting timestamps back from an api in this format
2014-09-27T00:00:00-07:00
where this part is in UTC
2014-09-27T00:00:00
and this part is the timezone offset
-07:00
When converting to a moment I can't figure out how to let moment.js know that the time I'm passing it is in UTC.
If I try this
var time = moment('2014-09-27T00:00:00-07:00');
console.log(time.format("YYYY-MM-DDTHH:mm:ss"));
time.local();
console.log(time.format("YYYY-MM-DDTHH:mm:ss"));
both console logs output the same
however if I do this
var time = moment('2014-09-27T00:00:00-07:00');
time.utc();
console.log(time.format("YYYY-MM-DDTHH:mm:ss"));
time.local();
console.log(time.format("YYYY-MM-DDTHH:mm:ss"));
It will accurately add 7 hours (my time difference from UTC) log it, remove the time again and log it again.
I've tried
var time = moment.utc('2014-09-27T00:00:00-07:00');
but even then the .local() method doesn't do anything.
What am I missing?
An additional related question... In standard ISO 8601 format is the time string understood to be local time or UTC? With the offset one could convert in either direction, I'm just not sure what the starting point is.
I am creating a new Entity and inside constructor I set the datetime like
function Project() {
this.created = moment().format();
}
which produce a result in console the current date and time
Sat Jun 07 2014 18:48:41 GMT+0500 (Pakistan Standard Time)
As soon as I call save changes and see the posted date in the network tabe it changes the hour part of datetime 2014-06-07T13:48:41.000Z
It looks like Breeze does this, may be I am wrong, Any suggestion how can I prevent this to happen?
Breeze is just serializing the date for transport It is not transformed at all. If you look it is 5 hours different in UTC meaning it will localize out the same when you moment.format it again.
If you want to re-localize it just use moment(yourDate).format(LL) or something similar.
http://momentjs.com/ and go to Internationalization section
I have created a BPEL process with wait activity, there are input for process start time (datetime) and interval(duration). while creating an instance(workitem) in process, it moves to wait and on console i got the error
<Mar 23, 2011 9:27:53 PM SGT> <Error> <oracle.soa.bpel.engine.bpel> <BEA-000000>
<<BPELReceiveWMP::__defineExpirationDate> Bad expiration date format, and this
expiration date will be ignored
java.lang.IllegalArgumentException: Duration has to start with 'P'.
Input payload for process is:
<inputVariable> <part name="payload"> <ns1:process> <ns1:startDate>2011-03-23T16:30:00.000+08:00</ns1:startDate> <ns1:interval>PT2M</ns1:interval> </ns1:process> </part> </inputVariable>
And in wait have putted
string(bpws:getVariableData('inputVariable','payload','/client:process/client:startDate'))
expression in "for" column
WaitForStart (pending)
Mar 23, 2011 9:27:53 PM Bad expiration date "2011-03-23T16:30:00.000+08:00"
Mar 23, 2011 9:27:53 PM Waiting for the expiry time "never".
environment is:
SOA 11.1.1.3.0
Jdeveloper: 11.3
If the input is "2011-03-23T16:30:00.000+08:00 PT2M" the problem is quite clear. The first part is dateTime while the second part is a duration. The element in BPEL expects a duration, so its value should be just "PT2M", which means 2 minutes. The first part of the string looks erroneous to me.