Anyone help me ...I am writing to get Date, Month and Year...I got errors
Could some body help me:
I am try to get Date, Month and Year
I got stuck, Anyone help me this:
public class DateMonth
public static void main(String[] args)
toDay = new toDay("February 21, 2002");
dayofWeek = today.getDay();
System.out.println("Current month is " + toDay.getMonth());
System.out.println("Current day is " + getDate());
System.out.println("Current year is " + toDay.getYear());
toDay.setDate(toDay.getDate()+60)
System.out.println("Sixty days from now is ");
System.out.println(toDay);
}
Try something like this:
import java.util.*;
public class DateMonth {
public static void main(String[] args) {
// Note: 0 = January
Calendar calendar = new GregorianCalendar();
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
// 60 days from now
calendar.add(calendar.DATE, 60);
System.out.println("\nSixty days from now");
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
}Remember that January is 0!
Take a look at the GregorianCalendar class:
http://java.sun.com/j2se/1.3/docs/api/java/util/GregorianCalendar.html
Hope this helps!
DesQuite
Similar Messages
-
Getting Day, month and year from Date object
hello everybody,
Date mydate = Resultset.getDate(indexField);
Now i would like to get day, month and year from mydate.
In another words, i'm looking for something equivalent to
mydate.getDay() as this method is deprecated.
Can somebody help me out please?
Thank you in advance,swvc2000,
Here is a sample class that demonstrates two ways in which to do this.import java.util.*;
import java.text.*;
public class DateSplitter {
public static void main(String args[]) {
/* even though your date is from a result set,
pretend the following date is your date that
you are using. The try catch block is used
because I hand-crafted my date using
SimpleDateFormat. Substitute your date.*/
Date yourDate = null;
try {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
yourDate = formatter.parse("05/06/2000");
} catch (ParseException e) { }
//the following gets the current date
Calendar c = Calendar.getInstance();
//use the calendar object to set it to your date
c.setTime(yourDate);
//note months start at zero
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
System.out.println("Calendar Month: "+month);
System.out.println("Calendar Day: "+dayOfMonth);
System.out.println("Calendar Year: "+year);
System.out.println();
/* Simple date format can also be used to strip them
out of your date object. When you use it, notice that
months start at 1. Also, it returns string values. If
you need integer values, you will have to use
Integer.parseInt() as I did below. If you are
only concerned about the string values, just remove
the Integer.parseInt part. */
DateFormat formatter = new SimpleDateFormat("M");
month = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Month: "+ month);
formatter = new SimpleDateFormat("d");
dayOfMonth = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Day: "+ dayOfMonth);
formatter = new SimpleDateFormat("yyyy");
year = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Year: "+ year);
}//end main
}//end DateSplitter classtajenkins -
Can we modify the pnp selection screen and get only month and year?
Dear Freinds,
I have requirement where i have to modify the PNP selection screen. So with the help of report category and coding in AT SELECTION-SCREEN OUTPUT , i have modified all the fields relating to dates . i.e i have removed all the radio buttons (i.e Today, Current month,current year etc) and finally
i have landed with only Period ( PNPBEGDA & PNPENDDA range) . But i dont want the PNPBEGDA & PNPENDDA range , but i want only is the month and year ( i.e just like the PNPPABRP & PNPPABRJ)
on my selection screen along with the pernr .
i have used the below code to close all the fields except pnpbegda and pnpendda.
AT Selection-Screen output.
loop at screen.
IF screen-group4 = '098' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '092' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '094' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '100' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '104' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
endloop.
i.e on my selection screen i want only month & year combination and pernr -
when iam using the logical database PNP . Could any one please let me know how can i get only mon & year only on my selection screen .
If it is possible please let me know .
Thanks & regards
divya.Hi ,
The requirement is that the user doesnt want to enter the date range i.e for ex: 01012008 to 31012008.
As per the requirement the user will enter only the month and year only . so i on the selection screen
i want only the month and year only . Is there any means i can modify the date period which is there by
default (PNPbegda and PNPendda) on PNP selection screen. Instead of we givign to the user the
PNPBEGDA and PNPPENDA i want is only month and year .
AS already the code has already been written and now they have asked that they want only the month and year on the selection screen.
Please suggest me in this regard.If iam hiding all the buttons relating the dates fields, and now if iam adding the parameters for the month and year it is coming below below the fields pernr , personnel ara and subara , company code , payroll area, employee group of the standard fields of PNP selection screen , there by any body could please suggest me how to change.
regards
divya. -
Get day month and year of a date
Hi all i need to get the week day of a date, the week, the month, the year of a generic date.
Actually SimpleDateFormat is probably better. Calendar's months are opaque constants.
http://www.javaalmanac.com/egs/java.text/FormatDate.html -
How to get Week,Month and Year details from a date column
Hi frenz,
I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
I need month and year details as well based on this tran_date column.... can any one tell me how...
Thanks in advanceMy example for objects:
create or replace type date_object as object
centure number,
year number,
month number,
day number,
hour number,
minute number,
second number,
daypart number,
week number,
constructor function date_object(p_dt date)
return SELF as result
create or replace type body date_object is
constructor function date_object(p_dt date)
return SELF as result
as
begin
SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
SELF.year:= to_char(p_dt,'YYYY');
SELF.month:= to_char(p_dt,'MM');
SELF.day:= to_char(p_dt,'DD');
SELF.hour:= to_char(p_dt,'HH24');
SELF.minute:= to_char(p_dt,'MI');
SELF.second:= to_char(p_dt,'SS');
SELF.daypart:= p_dt-trunc(p_dt,'DD');
SELF.week:= to_char(p_dt,'IW');
return;
end;
end;
select date_object(sysdate),
date_object(sysdate).year
from dual;Regards,
Sayan M. -
How can i get the month and year of the current open Periode?
At the beginning of each month the booking period for the new month was not open,but i need to book material automatically with the last day of the old month. The booking period will change at the first working day between 13 and 17 a clock. when the booking period was changed i have to book with the current date.
How can i do this ??
Regards
RalfHi Ralf,
here's a complete example:
DATA: last LIKE sy-datum, "ultimo of last month
gjahr LIKE t001b-frye1,
buper LIKE t001b-frpe1.
last = sy-datum - sy-datum+6(2) .
PERFORM check_period.
IF sy-subrc <> 0.
ADD 1 TO last . "-> next month
PERFORM check_period.
IF sy-subrc <> 0.
MESSAGE a001(00) WITH 'no open fi period'.
ENDIF.
ENDIF.
*formatting for germany
CONCATENATE last+6(2) last+4(2) last(4) INTO bbkpf-budat.
WRITE: / bbkpf-budat.
FORM check_period.
MOVE last(4) TO gjahr.
MOVE last+4(2) TO buper.
CALL FUNCTION 'FI_PERIOD_CHECK'
EXPORTING
i_bukrs = bbkpf-bukrs
i_gjahr = gjahr
i_koart = '+'
i_monat = buper
EXCEPTIONS
error_period = 1
error_period_acc = 2
OTHERS = 3.
ENDFORM. " check_period
regards <a href="https://www.sdn.sap.com:443/irj/servlet/prt/porta
l/prtroot/com.sap.sdn.businesscard.SDNBusinessCard?u=i
Wo3ssHlIihvCrADIEGqaw%3D%3D">Andreas</a>
Message was edited by: Andreas Mann -
Get month and year from date type
Hi all,
I need to get the month and year from the date type.
For example select to_date('2011-01-17', 'yyyy-mm-dd') from dual;Result needed:
01-2011Any ideas?
thanks in advance,
Bahchevanov.Hello Bahchevanov,
if you need the date to compute something, then you can
TRUNC(SYSDATE,'mm')This will give you a date with the days removed -> 01.01.2011
Regards
Marcus -
Can anyone help me? When i try to download minecraft and open it up, it says that it gets damaged and it won't work. I have the Macbook Pro with Retina display
Hi AMD2, This worked for me
https://discussions.apple.com/thread/3241273?start=15&tstart=0 -
Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?
Are you in DSL? Do you know if your modem is bridged?
"Sometimes your knight in shining armor is just a retard in tin foil.."-ARCHANGEL_06 -
can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue
Hey damien555,
Thanks for the question, I understand how frustrating this may be. It sounds like the update process may have been interrupted, and to resolve the issue, we’ll need to restore your device in recovery mode with iTunes:
If you can't update or restore your iOS device
http://support.apple.com/kb/HT1808
Thanks,
Matt M. -
when i try to install snow leopard with install disk, it has me restart the computer instead of installing. can anyone help me figure out how to get the disk to actually install?
Ok, it's just a glitch that it's not auto-rebooting from the disk.
Please backup your personal files off the machine to a regualr external drive and disconnect all drives before doing anything
Take the 10.6 disk out and clean and polish the bottom with a very soft clean cloth and a tiny bit of rubbing alcohol to cut the oils.
Stick the disk in and reboot holding c key down, this will make it boot from the disk and you can install Snow Leopard that way. -
Can anyone help me with process of moving only my pics and music (purchased and imported cds) from a old G5 to a new iMac. Thanks Dan
The easiest way is to connect the G5 and your new iMac together via Firewire. Then you can use what is called "Target Disk Mode" which basically makes the G5 look like an external hard drive to your iMac. The potential gotcha is if your new iMac does not have a Firewire port. In that case, you need to get the Apple Thunderbolt-Firewire adapter in order to connect the two machines (as far as I know, all G5's had one or more Firewire ports). I have done this many times, it's easy and works perfectly.
Alternatively, you could connect both Macs to the same network and log into the G5 from your iMac. This involves going into System Preferences > Sharing on the G5 and turning on File Sharing and then logging in from your iMac to the G5 as if it were a server. (Logging in through the Finder or via Go > Connect to Server). This also works fine but it's a little more involved than using Target Disk Mode. I do this all the time and it too works fine.
Either way, once the two Macs are connected, you will use the Finder on your iMac to copy files/folders from your G5 the same as you would from any external hard drive. Regarding iTunes, you could just copy your entire iTunes library over to your iMac being careful to put it in the same relative folder location: /users/yourusername/Music/iTunes This method will preserve your playlists and album art. Alternatively you could go into iTunes and do Add to Library but I'm not completely sure doing it that way will bring over your album art and it certainly won't bring over your playlists.
I see no reason to use a separate external hard drive. It will just double the time it takes to transfer your files because you would first have to copy everything to the hard drive, then in a second step copy everything from the hard drive to your iMac.
Note: In all cases there is the possibility that you may need to change file & folder permissions on the things you copy over so you can access (read & write) to these folders & files once copied to your new iMac. This is not a difficult process. -
Hi there. Can anyone help with restoring my Mac to it's origin white, it has got very grubby. Thanking you.
From here:
http://forums.macrumors.com/archive/index.php/t-863188.html
"You can use the Magic Eraser to clean the white plastic."
"thanks for the Magic Eraser tip, I willtry that..so far I've been using disinfectant wipes, which work pretty well, too because of the alcohol in them" -
Can anyone help me out? This happens when i try and submit an epub file, i haven't had this before. "iTunes producer error 3000 character content of element "file_name" invalid."
This is the full messageYou really need to put your codes between the
[\code] tags
see http://forum.java.sun.com/features.jsp#Formatting
for more infoCode tags might make it look a little better, but there's still too darn much code. We're volunteers, after all. It'd be a lot of work to review all of this stuff. Can you demonstrate your problem with something smaller? Learn out how to do a combo box with just a page or two and then appy that to your big problem. That's how I'd do it. - MOD -
To get first date and end date after entering any month and year
Hi,
I need to to get first date and end date of a month and year in yyyyMMdd format. I am reading month and year from a properties file. But I don't know how to get the first date and End date in given format. The properties file gives me just text. But I don't know how to get the date format using this. I need this urgently. Can anyone help me to get code for this?
I am reading the fields as,
Properties props = new Properties();
props.load(new FileInputStream("AnyMonthVolume.properties"));
String date_month = props.getProperty("date_month");
String date_year = props.getProperty("date_year");
Thanks.I know this has been posted a while ago but incase someone looking for it, here is the code to get the end of current month date.
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date());
cal.set(Calendar.DATE, 1); //set the date to start of month
cal.add(Calendar.MONTH,1);
cal.add(Calendar.DATE,-1);
System.out.println(cal.getTime());
Maybe you are looking for
-
Target is not coming in KKBC_PKO report
Hi, In KKBC_PKO report showing actual cost for for the given period i.e 05. but the same time it is not showing the target cost. I have checked the COSP table for the target cost. It is also not there. In KKS5 report showing the target and Actual. Al
-
I am trying to download songs i recently purchased onto my ipod, they are not in my library but a seperate folder on i tunes ( dont know what happened there ) there is no cloud next to the new songs ! how on earth do sync them into my ipod. Please h
-
Change order quantity in sales order
Hi, I have a sales order created. Now i want to change the Order qty depending on certain conditions through an ABAP Program. Can any one tell me how to change it? I tried bapi SD_SALESDOCUMENT_CHANGE ..but couldn't succeed. I tried passing field to
-
Automatic testing of some external options
Hello, while executing one test case I need to do svn update and edit some file outside my launched application. I already got some ideas from https://www.eclipse.org/forums/index.php/t/805353/ One possibility would be to write a script and call it i
-
Cfdocument pdf rendering problem
When you create a PDF using cfdocument, the <I> </I> tag and <B> </B> tag renders incorrectly sometimes. When it's at the edge of the table, the text inside the tags is repeated twice. And sometimes, it truncates the space or spaces before the tag. O