A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Refactoring for Software Design Smells: Managing Technical Debt
this week in the
OO, Patterns, UML and Refactoring
Java in General
Joined: May 31, 2004
Oct 25, 2004 19:54:00
I have a problem getting the day from a
. I hope somebody can help me.
here is my sample code:
String currDate = "";
String month = "";
String year = "";
currDate = year+"-"+month+"-"+i;
I want to display only the date without the month and the year and get the day of that particular date. how to solve this problem? can anybody help me? thanks.
Author and ninkuma
Joined: Jan 10, 2002
Oct 25, 2004 20:17:00
Not much to do with
, so I'm moving this off to the
in General (intermediate) forum.
Asking smart questions
Books by Bear
Joined: Sep 14, 2001
Oct 25, 2004 20:19:00
I think you can use Gregorian Calendar..
Calendar calendar1 = new GregorianCalendar(); //It give us current time Calendar calendar2 = new GregorianCalendar(year, month, date); // It give us Gregorian calendar with specified date int date = calendar1.get(Calendar.DAY_OF_MONTH);//Returns date int dayOfWeek = calendar1.get(Calendar.DAY_OF_WEEK); //Returns day
You can refer to
and Calendar API to get specific purpose you need...
Hope this helps...
Correct me if I am wrong
Joined: Dec 06, 2001
Oct 26, 2004 18:20:00
class provides a slick way to do this with only a few lines of code:
DateFormatter df = new DateFormatter("yyyymmdd hhmm"); Date date = new Date(); String dateString = df.valueToString(date);
(Disclaimer: This code does not come with any warranty, explicit or implied. It has not been compiled or tested, so use at your own risk.)
Consult the API docs for further details.
Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Date problem
A question on java.util.Date
Retrive Month and Year
Crazy date program
request.getParameter retuning null
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015