Before(), after() method's precision in Date object?
Hi all,
I have two date objects and I am using the before and after methods for a decision process. I would like to know the precision of the above methods. Is the precision at the seconds, milliseconds, or nanoseconds level?
Any help is appreciated.
Thanks
Saravanan
excerpt from Date.java...
public boolean after(Date when) {
return getTime() > when.getTime();
}
Similar Messages
-
MI7.1 Delete the inserted data before sync for the upload only data object
Hi,
I have a upload only data which have insert bapi wrapper only. I am able to save the data and insert data but my problem is how to delete the data before it syncr. Is this possible?? Or must i create a delete bapi wrapper??
Thanks.Hi,
Thanks for you reply. I manage to delete the inserted data refer to the employee_ui sample application but the data still appear at the backend after sync. Any idea why this happen??
Using the following code i am able to delete the record at the devices. But when it sync the data still get insert to database table.
ZmovementZmovementheader header = (ZmovementZmovementheader) wdContext.nodeasset_services().nodegetZmovementHeaders().nodegetZmovementHeadersOutput().getCurrentElement().model();
ZmovementZmovementdetail detail = (ZmovementZmovementdetail) wdContext.nodeasset_services().nodegetZmovementDetail().nodegetZmovementDetailOutput().getCurrentElement().model();
header.removeFromZmovementdetails(detail);
root.commit();
thanks
Edited by: fcgan on Aug 28, 2008 10:17 AM -
Problem in getting the Date object based on the TimeZone
Hi,
I need to create a Date object that holds the time of the specified TimeZone.
I am using TimeZone and Calendar object for that, but when I call the Calendar object's getTime() method, it returns
a Date object that holds the local time.
Can somebody let me know what why?
Here is what I uses in my code.
TimeZone tz = TimeZone.getTimeZone("IST");
Calendar cal = new GregorianCalendar(tz);
System.out.println("Date of "IST" TimeZone = " + cal.getTime());
Instead of cal.getTime, if I do the following I am getting the values correctly.
int month = cal.get(Calendar.MONTH); // 0..11
int day = cal.get(Calendar.DATE); // 0..11
int hour12 = cal.get(Calendar.HOUR); // 0..11
int minutes = cal.get(Calendar.MINUTE); // 0..59
Can somebody let me know why I am not able to assign the Date of the TimeZone specified.
Is there anything wrong with the code?
SebIs there anything wrong with the code?No, only with your understanding of the Date class. From the API:
The class Date represents a specific instant in time, with millisecond precision.
The different time displayed for different TimeZones around the world are just that: a display format for the same instant in time.
To display the "instant in time" in a different TimeZone, use DateFormat. Here's a small sample:TimeZone tz = TimeZone.getTimeZone ("GMT");
Calendar c = Calendar.getInstance (tz);
System.out.println(c.getTime ()); // prints Tue Mar 18 02:56:53 IST 2008
DateFormat dtf = DateFormat.getTimeInstance ();
dtf.setTimeZone (tz);
System.out.println(dtf.format (c.getTime ())); // prints 9:26:53 PMIt's no different from formatting the same number in various ways: 10 decimal == 0xA hexadecimal == 012 octal == 1010 binary. Same value, different representation. Same intant in time, different local time for each zone.
Savvy?
cheers, db -
Date objects and prepared statements
Hi, I am trying to parse a String into a Date object with format "dd/MM/yyyy hh/mm/ss". Anyway, i have a method in a separate class which reads in a String and converts it to a formatted Date object.
static public Date convertToDate(String t) throws ParseException {
Date dd = new Date();
ParsePosition p = new ParsePosition(0);
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
//y, M, etc are retrieved as substrings of String t. I know these methods are deprecated as well
dd.setYear(y);
dd.setMonth(M);
dd.setDate(d);
dd.setHours(h);
dd.setMinutes(m);
dd.setSeconds(s);
String formattedDate = formatter.format(dd);
Date theDate = formatter.parse(formattedDate);
return theDate;
Anyway, I am trying to use this in an SQL statement because I am using an Access DB which has a field of Date/Time value. Is this correct to use a Date object then? I have a prepared statement -
PreparedStatement query = connection.prepareStatement(
"SELECT FText FROM wnioutput WHERE Id = ? AND Section = ? AND Start = " +
"? AND Field = ?");
//start is the Date object returned from the previous method in a separate class
query.setInt(1, id);
query.setInt(2, section);
query.setDate(3, formattedStart); - with this part, i get a setDate method not found, or something
query.setString(4, ch);
Can anybody tell me what the problem is? I know there are Date objects of java.util and java.sql. Should i be using an sql Date object? And if so, how, and where do I do this? Thank you!ok, i just tried
query.setTimestamp(3, new java.sql.Timestamp(formattedStart.getTime()));
where formattedStart is a java.util.Date object
and I get the following error message -
Error occured in getting endDateAndTime: java.sql.SQLException: Exception in databaseDisplay: the error message is:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
java.lang.NullPointerException
where endDateAndTime is
// takes in the startDateAndTime as a formatted String (before it is converted into a Date object)
public String getEndTime(int s, int ID, String stDateAndTime) {
String end = null;
gui g = new gui();
try {
String sql = "SELECT End FROM wnioutput WHERE Id = " + ID +
" AND Section = " + s +
" AND Start = '" + stDateAndTime + "' AND Field = 'Wind50m'";
ResultSet result = g.queryDatabase(sql);
if (result.next())
end = result.getString("End");
} catch (SQLException sqlex) {
System.out.println("Error occured in getting endDateAndTime: " + sqlex.toString());
return end;
Although this method worked fine before. So the error is in setting the date object in the prepared statement. Anymore suggestions?? -
Error passing in a date object
I'm calling Oracle CRM On Demand by generating a WS proxy of its WSDL file. There's a field of date datatype in CRMOD and in the java class, it accepts a Calendar object. Below is my code
Here's my code
1) I have a Date object
2) I found a piece of code on the internet to get the WS 2.0 ISO8601 DateTime format. This method will format my Date object and return a String as below
String dateString = "2011-09-08T00:00:00-0700-07:00";
3)
SimpleDateFormat dfISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
Date dt= dfISO8601.parse(dateString);
4)
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
5) customObject.setDStartDate(cal);
but it kept saying
"The value '11-09-08-07:00' cannot be converted to a date time value.(SBL-DAT-00359)"
It looks like Calendar reverts back to the default date formatting which does not conform to XSD format.
Do you have any idea?
ThanksFirst, you've to make up your mind in fixing what the question is otherwise every time it will end up "actually I have this rather than that... and need this rather than that...".
Actually I have a Date object and instead of parsing it, how can I call a Web Service method that accepts a Calendar type?So you have a Date object. The service accepts a Calendar type? What kind of service would that be?
For Web services v2.0, the data in SOAP requests conforms to XSD data formats.So that is a string of xs:date (date, not data?). Why would that be a Calendar type?
If you start with a Date object and want to pass a string of xs:date format, you do this, as I'd practically suggested all the ingredients already.
//dt being your date object
Calendar cal=Calendar.getInstance();
cal.setTime(dt);
String s=javax.xml.bind.DatatypeConverter.printDate(cal);
//you pass s to the soap message. -
I have three integer variables. They hold a specific hour, minute and second value. How can I get a date object representing the next day and the hour, minute and second which I have.
For ex new date() gives me the current time but i want tomorrows time at the specifies hour minute and second.
Message was edited by:
sonny1000Get a Date (e.g. new Date()).
Put that Date into a Calendar. (See the below
tutorials and Calendar's and GregorianCalendar's
docs. There should be a method that takes a Date or
a long. You might even be able to directly create a
Calendar representing "now." Check the docs.)
Use Calendar's add method to add one day. That will
give you 24 hour from now. If you want midnight--the
start of the day--use the set() method to set hours,
minutes, seconds, and millis to zero.
Calendar has a method for getting a Date object or a
long corresponding to the instant in time represented
by that Calendar. If it's a long, you can use it to
create a Date.
[url=http://www.javaworld.com/jw-12-2000/jw-1229-dates
.html]Calculating Java dates: Take the time to
learn how to create and use dates
[url=http://www.javaworld.com/javaworld/jw-03-2001/jw-
0330-time.html]Working in Java time: Learn the
basics of calculating elapsed time in Java
[url=http://www.javaalmanac.com/egs/java.text/FormatDa
te.html]Formatting a Date Using a Custom
Format
[url=http://www.javaalmanac.com/egs/java.text/ParseDat
e.html]Parsing a Date Using a Custom Format
Thanks :) -
Use After method in formatted date.
Hello everyone, does anyone know how to use .after method in date without time included?
My problem here is that when i use the .after method on dates it includes time, the result is that it is always true.
import java.util.Date;
public class CompareDateAfter{
public static void main(String[] args) {
Date firstDate = new Date();
Date secondDate = new Date();
secondDate = appointmentCheck.getAppointmentDate();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.format(firstDate);
dateFormat.format(secondDate);
if(firstDate.after(secondDate))
System.out.println("Second Date is initialized before First Date");
else
System.out.println("Second Date is initialized after First Date");
Example:
Thu Jul 23 00:27:22 CST 2009 (i got this by declaring a new date) is always after Thu Jul 23 00:00:00 CST 2009 (i got this from the database with the original value of 2009-07-23).
Thanks in advance, hope you can help me.
Edited by: xrookie24 on Jul 22, 2009 9:37 AMxrookie24 wrote:
What i meant is:
Thu Jul 23 00:27:22 CST 2009 (i got this by declaring a new date) is always after Thu Jul 21 00:00:00 CST 2009 (i got this from the database with the original value of 2009-07-21).Yes, it is, isn't it? So you want to know what to do about it? What I would do is to set the hours, minutes, seconds, and milliseconds of your "new date" to zero. A Calendar object is the most convenient way to do that. -
Hello!After I've done my last softwere update I couldn't buy or get any free apps on the apps store.There was an error on my paymant method.I reintrodius my data for the credit card and again error for my credit card.I've changed the credit card and the same.why???????
I have tried all those things I even updated the software to the new iOS system and it still did fix my problem.
What happened is that my garage band looks like it will open then it shuts down.
I have lot of important things on my garage band and I'm afraid that if I uninstall it deleting it then reinstalling it all my work on it will be gone and I can't have that happen.
Everyday I am hoping that when i go to open the app that is will work but it doesn't it gets ready to turn on then it shuts off , the app doesn't even open all the way and turns off.
I really hope I don't have to erase it.
It'll say it's ,lading my songs then it shuts down .
If I waited for the App Store to come up with an update for garage band should I wait till then to update my app so it doesn't get damaged . I don't want to erase it and all my data get erased . I figured if I wait for an update then my garage band will reset itself but won't delete my data. I'm not sure if that will help. Is there anything you or anyone else might know that can help me with this matter ?
Thank you
Simachyahi -
After installing BAM there are no existing ADC Data Object
I am trying to install the Oracle Bam 10.1.3.1 and each time I am doing the install all services are up and runing, but when i am trying to define a report i get an error Data Object was deleted.
I saw the error and load the CustomParameters to the table via th ICommand exe, but :
1. it seems that the ADC install was failed (part of it). How can I fix it
2. Where can i find the xml files of the data objects so i will be able to load it manually?
With Best Regards and Thank inadvanced
ErezHi;
I had the same issue. Prior of uninstalling BAM10.1.3.1, i had only export orabam and orasagent schema. Then I install BAM10.1.3.3 into the development server where it has the same hostname and IP.
I then import back the original orabam and orasagent schema.
When i open BAM Studio, it lists all my original data objects. However when i click into any one of those, an error appear saying the data object does not exist. How can i overcome this issue?
thanks -
Master data object business content activation
Hello ,
How to activate business content for master data ingoobjects . Like 0p_plant .
I activated PP cube and just want to proceed now for masterdata with out missing it's attribute .
Should I drag infoobject and select dataflow before , Is it correct method ? But in this case , I am getting so many other object which i don't want .
I only want to activate master data object , ( it's datasources , transferrule , update rule and infopackage if possible )
PLease suggestHi Akshay,
you can very activate the object of your own choice by simple drag and drop.
Howcver, this is usually not recommended as you might miss objects which are very important in the data flow.
Apart from this you can also make selections of the objects from all the object included due to the option " before and after data flow" by checking or unchecking them while installing your content.
Regards,
Tapish -
Data objects in Unicode cannot be converted dump
Hi experts,
I am using a Custom business object which if run independently throws no error. We are upgrading 4.6 to ECC 6.0.It is unicode active.
The Business object contains methods for displaying a scanned document from IXOS server.
On executing work item (for decision step), there is a scanned document which shows up in a window. On closing the window,
there is a short dump with text 'Data objects in Unicode cannot be converted dump'.
There are both Before Work item execution method and an After Work item execution method attached in the Methods tab of the task.
In the After Work item method there is ARCHIVWINDOW_CLOSE function module used. Could there be a problem with this?
Please help.
Regards,
Garima.Actually, there is no problem in Workflow.It is because we are upgrading from 4.6 to ECC 6.0.
I have used CREATE OBJECT ole class and FREE OBJECT statements.
There is a dump ' Data objects in Unicode cannot be converted dump ' from function AC_FLUSH_CALL_INTERNAL
occuring when FREE OBJECT statement is executed.
Please suggest a solution to this.
Regards,
Garima. -
See, here's the thing with dates in java, the way i see it. We used to have Date, but Date wasn't international so we got Calendar. But some things, like SimpleDateFormat, still expect java.util.Date. java.sql.Date is out there somewhere, too. None of them have direct support for date differences (i.e. dateA - dateB = 8 days, or whatever). Now you're probably reading this thinking "Java supports all of this" and you're right. Calendar has a getTime method that returns a Date, and i can just pass THAT to SimpleDateFormat. With a little math, getTimeInMillis can be used to find the difference in two Calendars. But i got to thinking, "There should only be one Date object i need to think about," and since i don't ever have enough to do at work i put one together. I don't know if any of you are going to care enough to use it, mostly i'm just looking for advice on features i should add to it, inefficiencies in the design, stuff that's hard to understand, or whatever.
This is it:
*This catastrophe brought to you by SrA Meyerin.
*Proximo Satis pro administatio.
package awesomedate;
//The following are imported for the toFormattedString(), toUtilDate(), toSQLDate, and toCalendar() methods, respectively.
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.sql.*;
import java.util.TimeZone;
*This class is designed to be the ultimate date object. It stores dates accurate to the millisecond, has the ability to do date
*arithmetic (adding/subtracting days/months/whatever), date comparison, and date formatting. Also it can, at will, be used as any
*of the other date objects in the standard java API.
public class AwesomeDate
*Milliseconds from the epoch. This field is where everything starts.
private long millis;
* The current year. This is the only aspect of the current date that is stored in addition to the milliseconds. Everything else
* is calculated as needed.
private int year;
//The following six variables are fairly self explanatory. I'll explain them anyway.
*Milliseconds in one non-leap year. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public final static long MILLIS_IN_YEAR = 31536000000L;
*Milliseconds in one leap year. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public static final long MILLIS_IN_LEAP_YEAR = 31622400000L;
*Milliseconds in one day. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public static final long MILLIS_IN_DAY = 86400000;
*Milliseconds in one hour. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public static final long MILLIS_IN_HOUR = 3600000;
*Milliseconds in one minute. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public static final long MILLIS_IN_MINUTE = 60000;
*Milliseconds in one second. This can be passed to the "adjustDate()" method
* but mostly it is used to make my code more readable.
public static final long MILLIS_IN_SECOND = 1000;
*The number of days in each month.
private int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
*The timezone offset. GMT is 0, and the default, however, CST (where i live), is -6.
private int timeZoneOffset = -6;
*As the name would indicate, this is the number of milliseconds beyond 00:00 of jan 1 of the current year.
private long millisAfterYear;
*Basic constructor. Defaults to the current date and time. Works on Greenwich Mean Time, so it may seem off. To avoid this, multiply
*add your time zone offset * MILLIS_IN_HOUR to the time in milliseconds.
public AwesomeDate()
setTimeInMillis(System.currentTimeMillis());
*Fairly simple constructor. Sets time to the the number of milliseconds passed past the epoch.
public AwesomeDate(long millis)
setTimeInMillis(millis);
*This constructor sets the date to the year/month/day passed.
public AwesomeDate(int year, int month, int day)
setDate(year, month, day);
*This constructor sets the date time to the year/month/day/minute/hour/second passed.
public AwesomeDate(int year, int month, int day, int hour, int minute, int second)
setDate(year, month, day, hour, minute, second);
*When you have the number of milliseconds, the first thing you must calculate is year. Because the number of milliseconds in a
*year may vary, this is also the most difficult to calculate. This is the method that does it, though.
private void setYearAfter1970()
//I don't want to alter the actual number of milliseconds, so i make this variable and perform calculations on it.
long theseMillis = this.millis;
//Start at 1970 (the epoch) and work from there.
year = 1970;
long nextYear = MILLIS_IN_YEAR;
//In this loop i subtract the number of millis in whatever year. The condition is if i have enough millis to make it through
//another year.
while (theseMillis >= nextYear)
if (isLeapYear(year))
theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
nextYear = MILLIS_IN_YEAR;
else
theseMillis = theseMillis - MILLIS_IN_YEAR;
if (isLeapYear(year + 1))
nextYear = MILLIS_IN_LEAP_YEAR;
year++;
millisAfterYear = theseMillis;
this.year = year;
*Calculating the year from before 1970 must be done differently. It's pretty much just inverted.
private void setYearBefore1970()
long theseMillis = this.millis;
year = 1970;
long nextYear = MILLIS_IN_YEAR;
while (theseMillis <= 0)
if (isLeapYear(year))
theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
nextYear = MILLIS_IN_YEAR;
else
theseMillis = theseMillis + MILLIS_IN_YEAR;
if (isLeapYear(year - 1))
nextYear = MILLIS_IN_LEAP_YEAR;
year--;
millisAfterYear = theseMillis * -1;
this.year = year;
*Just what it sounds like. Pass it the number of milliseconds past the epoch and it will calculate the date based on that.
public void setTimeInMillis(long millis)
this.millis = millis;
if (millis >= 0)
setYearAfter1970();
else
setYearBefore1970();
*Returns the number of milliseconds from the epoch.
public long getTimeInMillis()
return this.millis;
*Returns the current year.
public int getYear()
return this.year;
*Sets the date to 00:00 of Jan 1 of the passed year.
public void setYear(int year)
this.year = year;
long theseMillis = 0;
if (year > 1970)
//Kind of like setYearAfter1970 method, except it's adding instead of subtracting. So actually it's the opposite.
for (int cntr = 1970; cntr < this.year; cntr++)
if (isLeapYear(cntr))
theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
else
theseMillis = theseMillis + MILLIS_IN_YEAR;
else
for (int cntr = 1970; cntr > this.year; cntr--)
if (isLeapYear(cntr))
theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
else
theseMillis = theseMillis - MILLIS_IN_YEAR;
//On a leap year there are 29 days in February. If not, there's 28.
if (isLeapYear(year))
daysInMonth[1] = 29;
else
daysInMonth[1] = 28;
//This variable helps me calculate denominations of time that are below year.
millisAfterYear = 0;
setTimeInMillis(theseMillis);
*Sets the month to the one that you passed, 0 being January and 11 being December.
public void setMonth(int month)
if (month < 0 || month > 11)
throw new ArrayIndexOutOfBoundsException(month);
long theseMillis = getTimeInMillis();
int days = 0;
setYear(this.year);
if (getTimeInMillis() > 0)
theseMillis = theseMillis - getTimeInMillis();
else
theseMillis = theseMillis + getTimeInMillis();
for (int cntr = 0; cntr < month; cntr++)
days = days + daysInMonth[cntr];
millisAfterYear = days * MILLIS_IN_DAY + 1;
setTimeInMillis(getTimeInMillis() + millisAfterYear);
*Returns the month stored in this object. With this object 0 represents January and 11 represents December.
public int getMonth()
long theseMillis = millisAfterYear;
int cntr = 0;
while (theseMillis > (MILLIS_IN_DAY * daysInMonth[cntr]))
theseMillis = theseMillis - MILLIS_IN_DAY * daysInMonth[cntr];
cntr++;
return cntr;
*Set the day of month to the one passed.
public void setDayOfMonth(int day)
if (day < 1 || day > daysInMonth[getMonth()])
throw new ArrayIndexOutOfBoundsException(day);
setMonth(getMonth());
//Internally, this actually works starting at zero, however to anyone using this class it appears to start at 1. Therefore
//i must subtract one here.
long addMillis = MILLIS_IN_DAY * (day - 1);
millisAfterYear = millisAfterYear + addMillis;
setTimeInMillis(getTimeInMillis() + addMillis + 1);
*Returns the day of month.
public int getDayOfMonth()
int days = (int)(millisAfterYear / MILLIS_IN_DAY);
int cntr = 0;
while (days >= daysInMonth[cntr])
days = days - daysInMonth[cntr];
cntr++;
//Internally this class stores dates starting at zero, but i want it to look like it starts at 1.
return days + 1;
*Sets the time to the currently selected day at the passed hour on the hour. uses 24 hour clock.
public void setHour(int hour)
if (hour < 0 || hour > 23)
throw new ArrayIndexOutOfBoundsException(hour);
setDayOfMonth(getDayOfMonth());
long addMillis = MILLIS_IN_HOUR * hour;
millisAfterYear = millisAfterYear + addMillis;
setTimeInMillis(getTimeInMillis() + addMillis);
*Returns the hour (but not how many minutes past the hour).
public int getHour()
long millisAfterDay = millisAfterYear % MILLIS_IN_DAY;
return (int)(millisAfterDay / MILLIS_IN_HOUR);
*Set the minutes past the hour. Works 0-59.
public void setMinute(int minute)
if (minute < 0 || minute > 59)
throw new ArrayIndexOutOfBoundsException(minute);
setHour(getHour());
long addMillis = MILLIS_IN_MINUTE * minute;
millisAfterYear = millisAfterYear + addMillis;
setTimeInMillis(getTimeInMillis() + addMillis);
*Returns the minutes past the hour, 0-59.
public int getMinute()
long millisAfterHour = millisAfterYear % MILLIS_IN_HOUR;
return (int)(millisAfterHour / MILLIS_IN_MINUTE);
*Sets the seconds past the minute, 0-59.
public void setSecond(int second)
if (second < 0 || second > 59)
throw new ArrayIndexOutOfBoundsException(second);
setMinute(getMinute());
long addMillis = MILLIS_IN_SECOND * second;
millisAfterYear = millisAfterYear + addMillis;
setTimeInMillis(getTimeInMillis() + addMillis);
*Returns the seconds past the minute, 0-59.
public int getSecond()
long millisAfterMinute = millisAfterYear % MILLIS_IN_MINUTE;
return (int)(millisAfterMinute / MILLIS_IN_SECOND);
*The more commonly seen set method of other date objects. Sets the date/time to 00:00 of the year/month/day passed. Convenience method
*for setDate(int year, int month, int day, int hour, int minute, int second).
public void setDate(int year, int month, int day)
setDate(year, month, day, 0 , 0 , 0);
*Sets every date/time field.
public void setDate(int year, int month, int day, int hour, int minute, int second)
setYear(year);
setMonth(month);
setDayOfMonth(day);
setHour(hour);
setMinute(minute);
setSecond(second);
*Returns yes if the stored date is a leap year. A leap year is every year that is divisible by four unless it is divisible by 100
*unless it is also divisible by 400.
public boolean isLeapYear()
return isLeapYear(this.year);
*For internal use. Returns if the passed year meets the criteria for a leap year.
private boolean isLeapYear(int year)
boolean leapYear = false;
if (year % 4 == 0)
if (year % 100 != 0)
leapYear = true;
else if (year % 400 == 0)
leapYear = true;
return leapYear;
*Returns the difference in milliseconds between the time stored in this object and the millis passed to this method.
public long getDifferenceInMillis(long millis)
return getTimeInMillis() - millis;
*Returns the difference in milliseconds between this date and the date passed to this method.
public long getDifferenceInMillis(AwesomeDate otherDate)
return getDifferenceInMillis(otherDate.getTimeInMillis());
*Designed to be a wrapper method for the getDifferenceInMillis method. This method changes millis into years/days/whatever. Pass
*the number of milliseconds you have to convert in the first parameter. The second parameter should be the type of denomination you
*want (year, day, whatever). Use the MILLIS_IN_* fields associated with this object. Also bear in mind when workin with years that
*some years are leap years, so in extreme cases of differences of 365+ years you may gain/lose a year.
public static int toGreaterDenom(long millis, long denom)
return (int)(millis / denom);
* The first argument is how many of whatever (days, months, years, etc.) to add (use negative numbers to subtract). For the second
* argument pass one of the MILLIS_IN_* fields. Thus, to add two hours would be
* <code>
* AwesomeDate.adjustDate(2, AwesomeDate.MILLIS_IN_HOUR);
* </code>
public void adjustDate(int amount, long typeMillis)
setTimeInMillis(this.millis + amount * typeMillis);
*Returns an object of type java.util.Date set to the date/time stored here.
public java.util.Date toUtilDate()
long offset = TimeZone.getDefault().getRawOffset();
return new java.util.Date(getTimeInMillis() + -1 * offset);
// return new java.util.Date(getTimeInMillis());
*Returns an object of type GregorianCalendar set to the date/time stored here.
public GregorianCalendar toGregorianCalendar()
long offset = TimeZone.getDefault().getRawOffset();
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(getTimeInMillis() - offset);
return cal;
*Returns an object of type java.sql.Date set to the date/time stored here.
public java.sql.Date toSQLDate()
long offset = TimeZone.getDefault().getRawOffset();
return new java.sql.Date(getTimeInMillis() - offset);
/** Format the date using the string that you pass. Works just like the SimpleDateFormat object. Infact, it uses one! Heres
*how it works:
*Letter Date or Time Component Presentation Examples <br>
*G Era designator Text AD <br>
*y Year Year 1996; 96 <br>
*M Month in year Month July; Jul; 07<br>
*w Week in year Number 27 <br>
*W Week in month Number 2 <br>
*D Day in year Number 189 <br>
*d Day in month Number 10 <br>
*F Day of week in month Number 2<br>
*E Day in week Text Tuesday; Tue <br>
*a Am/pm marker Text PM <br>
*H Hour in day (0-23) Number 0<br>
*k Hour in day (1-24) Number 24 <br>
*K Hour in am/pm (0-11) Number 0 <br>
*h Hour in am/pm (1-12) Number 12 <br>
*m Minute in hour Number 30 <br>
*s Second in minute Number 55 <br>
*S Millisecond Number 978 <br>
*z Time zone General time zone Pacific Standard Time; PST; GMT-08:00<br>
*Z Time zone RFC 822 time zone -0800 <br>
public String toFormattedString(String format)
SimpleDateFormat formattage = new SimpleDateFormat(format);
return formattage.format(toUtilDate());
*I overrode the toString method. Now it tells everyone how awesome my AwesomeDate is.
public String toString()
String output = "John's Awesome Date!";
output = output + " Millis: " + getTimeInMillis();
output = output + " Year: " + getYear();
output = output + " Month: " + getMonth();
output = output + " Date: " + getDayOfMonth();
output = output + " Time: ";
if (getHour() < 10)
output = output + "0" + getHour();
else
output = output + getHour();
if (getMinute() < 10)
output = output + "0" + getMinute();
else
output = output + getMinute();
output = output + " Seconds: " + getSecond();
return output;
public static void main(String[] psvm)
AwesomeDate blah = new AwesomeDate();
GregorianCalendar blah1 = new GregorianCalendar();
GregorianCalendar blah2 = new GregorianCalendar();
}The reason Callendar is so complicated is that it is trying to solve a very complicated problem.
You don't appear to support leap seconds (of which there can be upto 2 in any time interval)
http://www.timeanddate.com/time/leapseconds.html
Some of your code will not work for large dates very well (seems to iterate over the years). Try using your date class for astronomical or geological calculations. them big numbers will make your code slow at the moment.
You don't seem to support timezones or transitory offsets (BST vs GMT). You most definately don't handle changes to timezone offsets that have occured in the past or historical daylight savings time offsets (they have not always been the same)
The difference between two calendars is a "duration" a duration means nothing unless it is applied to a caledar/date (although you may be able to get away with it if the duration is always stored in millis) -
Hi All,
following piece of code was working fine in 4.6 C but in ECC 6.0 I get the following error:
" "END_OF_RECORD" must be a character-type data object (data type C, N,D, T or STRING) . "
I tried type-casting with field symbols but still not able to remove the error. Cannot convert end_of_record directly to type C as it may hamper the functionality. Plz advice how to remove the error without converting type x to type C
In the following code :
DATA: DELIMITER TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
end_of_record TYPE x.
SPLIT data_file_i AT delimiter INTO it_ekko-rtype
it_ekko-ebeln
it_ekko-bsart
it_ekko-lifnr
it_ekko-bedat
it_ekko-ekorg
it_ekko-ekgrp
it_ekko-bukrs
it_ekko-zterm
it_ekko-zbd1t
it_ekko-zbd1p
it_ekko-zbd2t
it_ekko-zbd2p
it_ekko-zbd3t
it_ekko-inco1
it_ekko-inco2
it_ekko-waers
it_ekko-wkurs
it_ekko-kufix
it_ekko-verkf
it_ekko-telf1
it_ekko-ihrez
it_ekko-unsez
it_ekko-angnr
it_ekko-ihran
it_ekko-submi
it_ekko-loekz
end_of_record.
where all these fields except " end_of_record " are of character type and "data_file_i " is a character type structure as defined below:
DATA :
BEGIN OF data_file_i OCCURS 0,
record(1000),
END OF data_file_i,Type X is not allowed in Unicode. When a field is declared as Type X with Value u201809u2019 or any other value, it can be resolved by using classes.
Before Unicode
CONSTANTS: c_hex TYPE x VALUE '09'.
Resolution:
Itu2019s work for any value of x.
First a temporary field of Type c should declare. Following class will convert Type x variable into type c.
Example:
CONSTANTS: c_hex TYPE x VALUE '09'.
DATA: LV_TEMP TYPE STRING.
DATA: LV_TMP TYPE C.
TRY.
CALL METHOD CL_ABAP_CONV_IN_CE=>UCCP
EXPORTING
UCCP = c_hex
RECEIVING
CHAR = LV_TMP .
CATCH CX_SY_CONVERSION_CODEPAGE.
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
ENDTRY.
CONCATENATE I_OUTPUT-BKTXT I_OUTPUT-BVORG
I_OUTPUT-BUDAT I_OUTPUT-MESSAGE INTO
SEPARATED BY LV_TMP.
I_BUFFER = LV_TEMP.
CLEAR LV_TEMP.
CLEAR LV_TMP.
OR
Note: It works only for type x value 09.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: c_hex TYPE c VALUE
abap_char_utilities=>HORIZONTAL_TAB. -
Add/Remove data object from dataset
Hello,
I was working out a way to add and remove data from a dataset
on the fly and could not figure out any built in methods to do
this.
As I have decided to include spry in my project I like to try
and utilise as much as of its code as possible since it is
complicated to explain I have created a simple example – a
colour picker! (thought it might be more interesting…) of
what I am trying to achieve at
http://www.freshfresh.co.uk/spry/
- if you have a go on this and maybe look at the source code (all
the JS is embedded in HTML there are no modifications to other the
other core files). I have only used spry effects etc, including the
‘accordion’ – which I have become quite attached
to, it is really good for condensing pages down.
You will see I am using the setDataFromDoc method to create
the dataset – I tried the .data = myArrayOfData; .dataHash =
hashTable; method i.e. creating from an object rather than array
but it did’nt seem to play ball with the
addDataChangedObserver method – it did’nt update itself
each time it was modified (I am sorry I cannot remember exactly
what I did – but I tried all kinds of ways…). I stuck
with the string method because it worked - each time my new dataset
changed it updated itself on the screen (you will have to have a
look to understand.....sorry!!), but I would be interested to know
how such a thing could be implemented using the object route if you
believe this would be more efficient.
My second question is more simple – is there a shorter
way to add and remove a data object from a dataset? – as you
can see from the source code I have effectively created an
‘interface’ to do these tasks…. I could’nt
work out whether these methods are already built in. Maybe they
are?
Third question is… to extract a data object from a
dataset I use the .dataHash[the_row_id] method – is this the
right thing to do or could it lead to complications… that is
using methods that might supposedly be private?
Fourth question (observation really) – whilst creating
that colour picker example I went over board with my datasets and
loaded in several palettes some of which had over 1000 elements or
data objects. Which inevitably was very slow (on my computer
anyway) – but it got me thinking about trimming the contents
of my spry regions for better performance. I am I right in thinking
that the less HTML etc that there is in a spry region the quicker
SPRY will process it. For example say you had spry repeat with an
image tag in with some onclick, onmousover, onmouseout, style
attributes etc and compare this to a spry repeat with a simple
image with minimal attributes set. I suppose what I am trying to
say is – does spry ‘store’ all the contents of
each spry region somewhere? Or does it just process it and leave it
to the browser dom?
Fifth observation.... I find it really difficult to explain
computer technicalities in writing. It must be tough reading these
posts.... I know I find it difficult sometimes when dealing with
written end user feedback!
AndrewJust clarifying my questions a bit further....
I found some old code regarding question 1 by using the
object method I mean something like this...
var mySwatches = [{'@hex':'ff0000'},{'@hex':'00ff00'}];
var hashTable = [];
function createDs(){
for (var i = 0; i < mySwatches.length; i++)
mySwatches
.ds_RowID = i;
hashTable = mySwatches
dsMySwatches.data = mySwatches;
dsMySwatches.dataHash = hashTable;
dsMySwatches.loadData();
i.e. not writing out a whole XML string string as the online
example does. When using this way I did'nt seem to be able to get
the HTML to refresh. I tried using [
Spry.Data.updateRegion('mydata'); ] after recreating the dataset I
also tried adding an [ .addDataChangedObserver ] (like in the
string example) amongst numerous other ways but it just would not
work like the string way. - Maybe I did something wrong somewhere.
In question 3 I refer to the [ .hash ] method .... its not a
'method' its a 'property' - my question should read - is it ok to
access private properties (from a browser campatiblity/security
point of view) that do not have specific methods to gain access to
them. I suppose it does'nt really matter with JS...
In question 4 I mention minimising the amount of code in a
spry region to speed it up. A clearer example of this might be for
example - a gallery with lots of images. As we know there will be a
slight delay as SPRY writes all the html so to speed up that intial
write I strip out all the image attributes such as onlclick do
this, onmouse over do that... and add these after the images have
loaded using a seperate function similar to my
fillSwatches(ds,prefix) function in my online colorpicker example.
I suppose it like a 2 tier processing of all the data. SPRY does
the intial display writing to get everything in place and then
another pass is made over to add any further functionality
adjustments etc. I am still not sure if that makes any sense!
***edit
Also on the subject of speed and the application as a whole
i.e. including my PHP - In one example I was creating I ended up
with an XML structure where each node has over 14 attributes i.e.
<somenode att1=”x” ……..
att14=”z”/> - as the file grew it obviously took
longer to process particularly on the server side, i.e. added all
those attributes just slowed it all down. So I did
this…… <somenode att1=”x:y:z” /> i.e
condensed selected attributes into a string that I could explode
later on.
Obviously this limits SPRYS ability to access the attributes
using the {attr} syntax. I had to create a function to explode the
array and do the ‘necessary’ on a second pass over the
data – this works ok for me. But its interesting that in this
particular case the server could not refresh the XML in an
acceptable time without doing this – just thought that might
be interesting to you. I suppose technically what I am doing is
abusing the concept of an XML structure and simply using it as a
‘carrier’ to feed my application …. Which I
suppose is where JSON comes in…. which is a bit more compact
and maybe faster to manipulate on both the server and client side
– I don’t really know, I have never used it –
just throwing ideas around!!
Andrew -
Why is data object completely emptied by XSLT on Output Data Association?
I have an activity in a BPM 11g workflow that invokes a DbAdapter that does a Select, which may not return any rows in the normal course of processing. My Data Associations for the Output uses an XSLT to map the returned values into one of my process data objects, accounting for the fact they could be empty because no row was found.
The problem: While I only mapped one column from the results of the Select into my data object using an XSLT, when no row is returned, all other values are removed from my data object. I need those to remain intact in the data object.
Why is that? How can I prevent that from happening?
More details...
Here is a snippet of my XSLT used to grab the result of the Select into my data object. Notice it only maps docId, does not include totalEarnings or bW2IsAttached.
<xsl:template match="/">
<ns1:InterfaceTable>
<xsl:if test='/ns0:AccountingDataCollection/ns0:AccountingData/ns0:docId != ""'>
<ns1:docId>
<xsl:value-of select="/ns0:AccountingDataCollection/ns0:AccountingData/ns0:docId"/>
</ns1:docId>
</xsl:if>
</ns1:InterfaceTable>
</xsl:template>
Here's my process data object contents before the DbAdapter activity runs the Select. Notice it includes docId, totalEarnings and bW2IsAttached.
<?xml version="1.0" encoding="UTF-8" ?><MyTestData xmlns="http://xmlns.oracle.com/bpm/bpmobject/Data/MyTestData">
<docId>123456</docId>
<totalEarnings>100.0</totalEarnings>
<bW2IsAttached>false</bW2IsAttached>
</MyTestData>
Now after the Select runs, and no row is found (which can happen), I end up with this empty data object:
<?xml version="1.0" encoding="UTF-8" ?><MyTestData xmlns:ns1="http://xmlns.oracle.com/bpm/bpmobject/Data/MyTestData" xmlns="http://xmlns.oracle.com/bpm/bpmobject/Data/MyTestData"/>
I need the totalEarnings and bW2IsAttached fields to remain in the data object. How can I do that?I tried using the data object as a second data source to map the values back to themselves, but that did not work for some unknown reason. Perhaps I'll try that again.
The only reason I'm using an XSLT is to handle the case of no row returned from the DB Select. So if there is another way to check that, this would be fine. How can I check using an exclusive gateway for a row returned? I just tried to create this setup, but the data object containing the row read from the service activity is not available in the gateway for checking. This would be the ideal solution if you could tell me how to access the data object holding the result of the Select in the gateway. Thanks!
Maybe you are looking for
-
Problem with Facebook and instagram after istalling iOS 7.1. Can not open them!
Problem with Facebook and instagram after istalling iOS 7.1. Can not open them!
-
Using Boot Camp to install Windows XP: problems with display going blank
I have a new Mac mini (early 2009) connected to an older NEC MultiSync LCD (VGA only) display through a KVM. I initially used the Apple Mini DisplayPort to VGA adapter to make the display connection. All worked fine with Mac OS X, but when I attempte
-
I have set my daughter up her own Itunes on my pc but, despite all the settings being right and having logged in on her own account it will not sync music. the first time she tried it wiped any music off that is on there and now will go through sync
-
Add Supported Channels Airport extreme Macbook Pro 15' late 2010
My wireless network at school recently added another router under our classroom. The channel for this connection is channel 13 which is not supported under the default supported channel settings. I was wondering if there is way to add or change these
-
ATT00001.htm attachment in Outlook when sent with Apple Mail - SOLVED!
Hi All, We recently discovered the problem where emails with attachments sent from Apple Mail were being received in Outlook, blank but with BOTH the attachment and the email itself as an ATT00001.htm attachment! I've discovered that the problem kick