Servlet- Date -- Name of the Day
I would like to write a servlet which accepts any "Date" from the user through a html page and prints the "Name of the Day" like "monday or tuesday...etc".
I am getting with this code can anyone check this pls
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.text.*;
import java.util.*;
public class findday extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
final String[] dayNames={"Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday"};
String str=request.getParameter("param1"); //parameter name
Date dt=DateFormat.parse(str); //converting string to Date format
GregorianCalendar calendar= new GregorianCalendar(dt); // creating a new object with the date
int dayOfWeek=calendar.get(calendar.DAY_OF_WEEK); // finding the day of week
String dayName=dayNames[dayOfWeek-1]; //converting the day into Name
out.println("<html>"); //output to browser
out.println("<body>");
out.println(dayName);
out.println("</body>");
out.println("</html>");
}thank u
Similar Messages
-
Name of the day from date based on the logon language
Hi All,
Could anyone help me with any function module which gives the name of the day after entering the date. but the name of the day should be language specific. I know DATE_COMPUTE_DAY_ENHANCED gives the name of the day but this is in english. I want the name/ description based on the logon language.
For example, I login in EN and I execute the above function module for date, 19.10.2010. so the weekday is Thursday. but this 'thursday' should be given in the logon language not the same even if I login in DE etc.
Thanks a lot in advance!!
Regards,
SwathiHi Swathi,
You can try to use FM DATE_COMPUTE_DAY to get the day ID, and then consult table T246 or execute FM DAY_NAMES_GET to get the day description in the desired language.
Kind regards,
Garcia -
Getting the name of the day of week, like Monday, etc
I have a query that has dates down the rows. Next to this date we want the the actually name of the day like Monday. My thoughts were to create this in an update rule but i was asked to do it via a custmer exit in the query. i am not sure it will work there? will it return for each row with a date if I put the varialbe in the row?
I think i misunderstood you.
I believe you will need a virtual characteristic for accomplishing this.
If you are new to this topic there is a good how to that can help.
The basic idea should be that you'll populate the virtual char on the fly.
The backdrwas are: performance, you will need to have "date" in the drill down, some extra development work etc'.
I believe that the way to go is with update rules.
Regards,
Gili -
Is there a way to repeat an activity in the calendar monthly on the same day, i.e., the 2nd Wednesday of each month? ( I can repeat on the date but not the day of the month.)
Not with the stock calendars app.
-
How to set the default value of an item type DATE PICKER to the day of yest
Hi
How to set the default value of an item type DATE PICKER to the day of yesterday ?
Thank you very much !
Christian.Hi Christian,
Have a look at this thread Re: Default the Date Picker to Today
It covers this issue in detail.
Regards
Paul -
Is there any function to get the name of the days?
Hi,
I'm using oracle 10.2.0.1.0
Is there any function to get the days of the week?
like i need to get sunday,monday,tuesday.....saturday.
I know i can use union and select the name from dual one by one.
But just want to know whether there is any other way.
I need to show the 7 days in a poplist in my form, thats the requirement
ThanksDavid_Aldridge wrote:
BluShadow wrote:
Note: you may want to include "fm" in the format mask, otherwise the name of the day is padded with spaces:
SQL> ed
Wrote file afiedt.buf
1 select replace(to_char(dt,'Day'),' ','*') as fmt1
2 ,length(to_char(dt,'Day')) as length_fmt1
3 ,replace(to_char(dt,'fmDay'),' ','*') as fmt2
4 ,length(to_char(dt,'fmDay')) as length_fmt2
5 from (select TRUNC(SYSDATE ,'DAY')+Level-1 dt
6 from dual
7 connect by Level<8
8* )
SQL> /
FMT1 LENGTH_FMT1 FMT2 LENGTH_FMT2
Monday*** 9 Monday 6
Tuesday** 9 Tuesday 7
Wednesday 9 Wednesday 9
Thursday* 9 Thursday 8
Friday*** 9 Friday 6
Saturday* 9 Saturday 8
Sunday*** 9 Sunday 6
7 rows selected.
SQL>
I think you should use a pl/sql function for this.
Nah ... just joking.
I'd be tempted to just use a union all statement to return the seven literals. People will look at it and know exactly what it does.Yeah, agreed, I was just demonstrating that the format mask of a to_char(..., 'Day') pads with spaces, which seems to have been missed in the above answers. ;) -
Can I get the date to display along with the day and time
can I get the date displayed with the day of week and time?
Hi Mary, you can, but what version of OSX are you running on what Mac?
See if this helps for starters...
http://paulstamatiou.com/how-to-display-date-in-os-x-menu-bar -
Split Data from Month to Days in the Bex Report
Hi Gurus,
I have a Actual and Plan data. Actual data is on daily basis and Plan data is in monthly basis.....
Requirement is : User will be entered Calendar Day ( any day of the month for example : 06/18/2010) to bring Month to date on both Actual and Plan data. Like for example if user enters the date 18th June 2010. Then I need to pull from the beginning of the month to date up to that selection day( in our case 18 days).
Actual : I don't have issue getting the Month to date and Year to date because I have data on daily basis.
Plan : As I said data is on monthly basis. I want to break this data up to the day selected ( from 1st of the June month to 18th as given in example) by user. Like if you have amount is $5000 then my logic will be
CKF = (5000 * 18) / total number days in the month
Please provide help on this how to bring the data for Plan...
Thanks
Ganesh Reddy.ganesh,
in your data model convert date field to calander period and calander year .
once that is done
create restricted key figures
1) month to date
2) year to date
month to date - key figure is restricted to custom variable ( which populates calander period based on the date user enter)
year to date - key figure is restricted to custom variable (which populates calander year based on the date user enter )
hope you got it .
Thanks,
pk. -
1st Date (the day after last day of month)
Hy Just Keep on hearding the Pahle Tariq (1st date) ...The day before which our pockets will full
The day which makes Happy the day which shows the fruits of whole month ....For this day how many people eagerly wating ..How fast it comes that quick it goes ..But when it comes it always brings the pleasure ..
So what the plans ..i hope every one recieve some bonus(incentive) along with salary......Just let share any (funny) plans :and lets party and good is Week end too
Regards
sas>
saslove sap wrote:
> .i hope every one recieve some bonus(incentive) along with salary.....
Hmmm.True
Just let share any (funny) plans
For me no plans yet.
But since Raksha Bandhan is its own the way therefore my Sister has lots of plans and eagerly waiting for me to Arrive with hell lot of shopping in her mind
Cheers -
Errors when in Month view and how do I show (highlight) the day selected?
There are some annoying 'bugs' in my ical. When I are working in month view and I select a day in that month to copy or enter an item to there is no indication that ical has that day selected. When I paste some data to that day thinking I have it selected it, it may be in the correct day or in the previously selected day - surely this is an oversight on Apples part or am I missing something here?
Also sometimes after pasting data to the correct day iCal will 'update' and then send the data back to the day I copied it from!!
Any help appreciated.
MAC OS 10.9 on a Mac Mini.Hi,
You don't need to convert to a string and back again to do that. Use TRUNC to get the right day, and date arithmetic to get the right time, like this:
UPDATE fc_gq_source_analysis
SET effective_date = TRUNC (sample_date, 'MONTH')
+ (sample_date - TRUNC (sample_date))
WHERE sample_type = 'C'
TRUNC (sample_date, 'MONTH') is midnight on the 1st of the month that you want.
sample_date - TRUNC (sample_date) is the time that you want, expressed as a number of days (e.g., 9/24 of a day). -
The calendar typeface is so dim, I can barely read it. Name of days and date, but not the items I put in. Apple says they have no fix. Anyone else have this problem? Any solutions?
I agree and I found your post because I did a google search ical typeface dim.
If I find anything out, I will post back here. -
How to list local admins in AD as a txt file which has a name as date of the day
Hello,
I have a script which lists local admins of all hosts in Active Directory:
$Searcher = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$Searcher.Filter = "(objectClass=computer)"
$Computers = ($Searcher.Findall())
md C:\All_Local_Admins
Foreach ($Computer in $Computers)
$Path=$Computer.Path
$Name=([ADSI]"$Path").Name
write-host $Name
$members =[ADSI]"WinNT://$Name/Administrators"
$members = @($members.psbase.Invoke("Members"))
$members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty',
$null, $_, $null) | out-file -append C:\All_Local_Admins\$name.txt
This script outputs HOST machine names as seperate txt files (HOST1.txt, HOST2.txt etc)
What I want is to get a single text file which name gets the date of the day (for example: 05082014.txt --> This file will include local admins of all hosts)
How should I modify above code to manage this?
Thank you very much.Try setting the file name outside of the loop.
$fname = "$((Get-Date).ToShortDateString().Replace('/','')).txt"
after the write host line add
$ | out-file
-append C:\All_Local_Admins\$fname
Change this line
$null, $_,
$null)
| out-file
-append C:\All_Local_Admins\$name.txt
to
$null, $_,
$null)
| out-file
-append C:\All_Local_Admins\$fname
See if that gives you what you need. -
1. when use com.oreilly.servlet.MultipartRequest to handle the file upload, can I change the upload file name .
2. how com.oreilly.servlet.MultipartReques handle file upload? do it change to byte ?
what different? if I use the following method?
File uploadedFile = (File) mp.getFile("filename");
FileOutputStream fos = new FileOutputStream(filename);
byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
fos.write(data);
fos.close();My questions are
1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the
file direction.
MultipartRequest multi =
new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
why some example still use FileOutputStream?
outs = new FileOutputStream(UPLOADDIR+fileName);
filePart.writeTo(outs);
outs.flush();
outs.close();
2) can I rename the file name when I use oreilly package? -
How to pass data accpeted in the form of a Table to the Servlet.
Hi guys. here is the problem:
A page is displayed and it contains a table with about 20 rows and 2 columns. Each cell of the Table contains a TextField. The user has to enter data into these TextFields.
How to i pass this 20 X 2 data to a servlet.
Adding to the trouble.. the number of rows is not fixed. and depends on how many rows of data the user wishes to enter.
A common example would be the line items in an ordering system.
Any ideas guys??
Thanks in advanceOr give all the textfields the same name.
<form>
<input type="text" name="tfvalue">
<input type="text" name="tfvalue">
<input type="text" name="tfvalue">
</form>Then in your servlet:
String[] vals = request.getParameterValues("tfvalue");
for(int i = 0; i < vals.length; i++){
String tfvalue = vals;
// do something with the value from textfield i
edit:
now that I think about it, I'm not sure if the value of an empty text field is submitted... -
Auto saving email attachments using date email received as the name of the attachment file
I would like to be able to batch save hundreds of email attachments in my inbox to a specified folder and use the date and time email was received as the name of the file. i found sample script that would give it timestamp but would prefer date and time of receipt. any help would be greatly appreciated.
thanks.I found the below script online but it does not seem to be naming correctly. it appears that the month always defaults to 12. perhaps somehow could suggest a fix?
set theAttachmentPath to (path to desktop) as text
tell application "Mail"
set a to selection
end tell
repeat with s in a
tell application "Mail"
set current_date to date received of s
set CurrentSender to sender of s
end tell
set current_date to AppleScriptDateToString(current_date)
tell application "Mail" to set Attached to mail attachments of s
repeat with ThisAttach in Attached
tell application "Mail" to set FileName to name of ThisAttach
if FileName ends with ".pdf" then
set FileName to current_date & " from " & CurrentSender & ".pdf" as text
set FileName to checknamewith_pdfsuffix(FileName, theAttachmentPath, false)
tell application "Mail" to save ThisAttach in theAttachmentPath & (FileName)
end if
end repeat
end repeat
on AppleScriptDateToString(a)
set b to current date
set monthnames to {}
repeat with i from 1 to 12
set month of b to i
set monthnames to monthnames & {(month of b) as text}
end repeat
set Y to (year of b)
set M to 0
repeat with t in monthnames
set M to M + 1
if t as text = (month of b) as text then
exit repeat
end if
end repeat
set M to Twodigits(M)
set D to Twodigits(day of b)
set hh to Twodigits(hours of b)
set mm to (minutes of b)
set ss to Twodigits(seconds of b)
return Y & "-" & M & "-" & D as text
end AppleScriptDateToString
on Twodigits(a)
return (characters -2 through -1 of (("0" & a) as text)) as text
end Twodigits
on checknamewith_pdfsuffix(n, D, looped)
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & " 1" & (characters -4 through -1 of n)) as text
checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & tmp & (characters -4 through -1 of n)) as text
checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
Maybe you are looking for
-
How do I add a blog area to a CS3 site and allow the client to add content?
My client has a web site she uses as a blog. It was built in iweb. I am redesigning it and want to use Dreamweaver. I am trying to research how to get started, I've only done static web sites so far. Any recommendations? She needs to be able to updat
-
MacBook Pro 2,2 won't pass memory test at boot
Hi Apple and Mac folks, I have a MacBook Pro 2,2 15", 2007 year model, equipped with 2,16 GHz Intel Core 2 Duo and 2 GB 667 Mhz factory-installed DDR2 SDRAM, running Mac OS X 10.4.11. SMC version is 1.12f5. Three months ago, when I was installing the
-
Dump error while filling the Setup table
Hi All, I am trying to fill the setup table.While filling the stup table for 2lis_03_BF datasource, i got the Dump error after some time. I have checked the data in Setup table and found 9000 records. Shall i proceed further by pulling the data from
-
Import CD in itune 11 does not work
import CD in itune 11, music is stored in the directory but it does show up in "music" panel.
-
Automate cable TV recording.....
Hi, Does anyone know of a Macintosh program that will allow me to record Component Video through my BlackMagic Intensity pro like a DVR or VCR? I don't mind doing it the old fashioned way ie.; set the start time and tell it how long.... and then walk