How to get ISO date format?
Hi there,
I'm having problem converting date to ISO format. How do I convert a date in the form of "Tue Sep 25 10:18:59 PDT 2007" to "20070925101859" ? Basically I am trying to get the date in "yyyymmddhhmmss". Below is my code, I keep getting "Tue Sep 25 10:18:59 PDT 2007", please help:
beginDateAsDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddhhmmss");
sdf.format( beginDateAsDate );
endDateAsDate = beginDateAsDate;
Calendar c1 = Calendar.getInstance();
c1.setTime(beginDateAsDate);
c1.add(Calendar.YEAR,2);
endDateAsDate = c1.getTime();
System.out.println("Begin Date is: " beginDateAsDate.toString());+
System.out.println("End Date is: " endDateAsDate.toString()); +
Output:
Begin Date is: Tue Sep 25 10:18:59 PDT 2007
End Date is: Fri Sep 25 10:18:59 PDT 2009
Use SimpleDateFormat, but don't forget to do this first:
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Similar Messages
-
How to get the Date format inside the table
I have a startdate column in the db in the format May 5, 2001 12:39:00 PM, when I query it from a view in this way : SELECT startdate, ... FROM ..., it returns the format in the db,
However I have to do this SELECT
decode(startdate, null, 'NOT START'), startdate), ... the result is 5-MAY-01,
then I tried this to_char(startTime, 'Month DD, YYYY HH:MI: A.M.') the results become May 05, 2001 12:39:00 PM. (more space between month and day, and 05 instaed of 5)
Does anybody know how to fix this, so I get exactly what is in the db?
Thanks in advanceNo matter what you do if you are storing a date in a column it will get stored in the Oracle's internal 7 byte date format.
The way you get it on retreiving it is as set by your date format. You can either change the default date format for the instance, the individual session or the individual SQL statement(in this case using to_char(date, 'format')).
If you want to store the date in a format you want to store you'll have to store it as char or varchar2.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by George ([email protected]):
I have a startdate column in the db in the format May 5, 2001 12:39:00 PM, when I query it from a view in this way : SELECT startdate, ... FROM ..., it returns the format in the db,
However I have to do this SELECT
decode(startdate, null, 'NOT START'), startdate), ... the result is 5-MAY-01,
then I tried this to_char(startTime, 'Month DD, YYYY HH:MI: A.M.') the results become May 05, 2001 12:39:00 PM. (more space between month and day, and 05 instaed of 5)
Does anybody know how to fix this, so I get exactly what is in the db?
Thanks in advance<HR></BLOCKQUOTE>
When you do to_char() with 'month' oracle blank pads the month to nine characters, the same goes with day too. So to get rid of it you'll have to trim() the month. And if you want to get a single digit for date less than 10 instead of 0x you'll have to do a bit of extra jugglery using translate() or replace().
Hope this helps
Naveen -
How to get the date format yyyy-mm-dd?
Hi,
I have an iphone (3.1.2) and would like to use the date format yyyy-mm-dd (international date format). Is the possible? If yes, how?
CheersI know of no other way to set the date format other than what I mentioned in my previous post. There are third party apps that will do what you want in the app. store, but they are not permitted to access the underlining software.
-
Hi all,
i have a very simple query.
I have report name like this "SALES REPORT DATE FOR "+Year(CurrentDate())
and it is showing result of SALES REPORT DATE FOR 2,014
but i want report look like SALES REPORT DATE FOR 2014
how i can change the year format form 2,014 to 2014
i am using 3.1
Thanks in advance
RanjeetHi
Find the below link
BI4.1 Business Layer Enhancements - Create Display Format -
How to get the Date in a particular format?
Hi,
How to get the Date in the below format? I will be passing the year in my method..
2/10/2003 9:46:52 PM
D/M/YYYY H:M:S A
public Date getDate (String year) {
Here i want to get the Date in this format
2/10/<Passed Year> 9:46:52 PM
ThanksThis is my code
public static Date getCalendar(Calendar calendar,int getYear) {
String formatted_date="";
int year = getYear;
int month = calendar.get(Calendar.MONTH+1);
int day = calendar.get(Calendar.DATE);
int hour = calendar.get(Calendar.HOUR);
int min = calendar.get(Calendar.MINUTE);
int sec = calendar.get(Calendar.SECOND);
int am_pm =calendar.get(Calendar.AM_PM);
formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
System.out.println("formatted_date is "+formatted_date);
o/p : formatted_date is 1/4/2006 1:44:21 PM
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
// DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
Date passdate = new Date();
try {
passdate = dateFormat.parse(formatted_date);
} catch (ParseException e) {
System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
return passdate;
Expected O/P is 3/1/2006 1:44:12 PM
} -
How to get the right format if I copy data off another source....
IWorks '08
I have a data source that I want to copy to Numbers and it posts it all in the first row, when I paste it. (Excel will automatically format it correctly). I've tried a number of different things and can't figure out how to get the data to post across the page. Can Numbers even do this?Welcome to Apple Discussions
Could you possibly have the insertion cursor blinking in the cell rather than just having a cell selected?
If the cursor is blinking in the cell, Numbers "thinks" you want to paste all of the content in that one cell. By just selecting the cell, the data will be separated if Numbers "sees" the separations. This used to be a problem, particularly with data copied from a web page in Safari, but is mostly fixed in Numbers '09. -
How to get the date time format in OCI
How to get a date time format in OCI instead of only date
You would have to use the OCIDateTime datatype for this. Refer to
OCI documentation for more details. -
How to get the date in 01-jan-2008 format
hi
how to get the date in 01-jan-2008 formatCheck this example of how to get this format..
TABLES: T247.
DATA: V_DATE TYPE SYDATUM.
DATA: V_STRING(20).
V_DATE = SY-DATUM.
SELECT SINGLE * FROM T247
WHERE SPRAS = SY-LANGU
AND MNR = V_DATE+4(2).
IF SY-SUBRC = 0.
CONCATENATE V_DATE+6(2) '-' T247-KTX '-' V_DATE(4)
INTO V_STRING.
WRITE: / V_STRING.
ENDIF.
or
make use of this FM
CONVERSION_EXIT_IDATE_OUTPUT
and see its documentation.
or
/: SET DATE MASK = 'DD-MMM-YYYY'
&DATE&
check with this.
if it is not working try to give space between DD and MMM and YYYY
all of the three work...choose whichever suits u
eg2:
Use FM:CONVERSION_EXIT_IDATE_OUTPUT
Check this Program.....
DATA:DATE TYPE D VALUE '20070912'.
DATA:DATE2(12) TYPE C.
DATA:FINAL_DATE(15) TYPE C.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
INPUT = DATE
IMPORTING
OUTPUT = DATE2.
CONCATENATE DATE20(2) '-' DATE22(3) '-' DATE2+5(4) INTO
FINAL_DATE.
WRITE:FINAL_DATE.
Eg:3
use FM MONTH_NAMES_GET by passing month_names-spras = 'E'
it will return the Mont names in month_names-KTX ( 3 cha short name ) & month_names-LTX ( Long text ). then concatenate 'DD''-' month_names-KTX & 'YY'
reward points if useful -
How to get the date for the first monday of each month
Dear Members,
How to get the date for the first monday of each month.
I have written the following code
SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
But it look bith complex.
Abhishek
Edited by: 9999999 on Mar 8, 2013 4:30 AMUse IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
select sysdate current_date,
trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
from dual
CURRENT_D FIRST_MON
08-MAR-13 04-MAR-13
SQL> Below is list of first monday of the month for this year:
with t as(
select add_months(date '2013-1-1',level-1) dt
from dual
connect by level <= 12
select dt first_of_the_month,
trunc(dt + 6,'iw') first_monday_the_month
from t
FIRST_OF_ FIRST_MON
01-JAN-13 07-JAN-13
01-FEB-13 04-FEB-13
01-MAR-13 04-MAR-13
01-APR-13 01-APR-13
01-MAY-13 06-MAY-13
01-JUN-13 03-JUN-13
01-JUL-13 01-JUL-13
01-AUG-13 05-AUG-13
01-SEP-13 02-SEP-13
01-OCT-13 07-OCT-13
01-NOV-13 04-NOV-13
FIRST_OF_ FIRST_MON
01-DEC-13 02-DEC-13
12 rows selected.
SQL> SY. -
How to change the date format YYYYMMDD to MM/DD/YYYY
Hi ,
How to change the date format YYYYMMDD to MM/DD/YYYY .
Ex : 20071008 to 10/08/2007
Is there any function module for this ??
Regards
RahulHi Sharma,
check the code:
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.
PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X', "SAP date format YYYYDDMM
date2 RADIOBUTTON GROUP rad1, "Date format like aprial31, 2006
date3 RADIOBUTTON GROUP rad1, "Date format like 31 apr,2006
date4 RADIOBUTTON GROUP rad1, "Date format like DD/MM/YYYY
date5 RADIOBUTTON GROUP rad1. "Date format like DD.MM.YYYY
SELECTION-SCREEN END OF BLOCK b2
FORM getmonth .
SELECT mnr
ktx
ltx
INTO TABLE T_month
FROM t247
WHERE spras = 'EN'.
IF sy-subrc NE '0'.
MESSAGE I "Message - Not able to get month values from the table T247
ENDIF.
ENDFORM.
DATA : temp_date(16) TYPE c,
temp1_date(60) TYPE c,
year(4) TYPE c,
daymonth(11) TYPE c,
daymonth1(11) TYPE c,
month(9) TYPE c,
day(2) TYPE c,
mon LIKE t247-ktx,
len TYPE i .
MOVE date TO temp1_date .
CONDENSE temp1_date NO-GAPS.
MOVE temp1_date TO temp_date .
IF date2 EQ 'X'. "The date format is like Aprial 31, 2007
CONDENSE temp_date NO-GAPS.
SPLIT date AT ',' INTO daymonth year.
IF STRLEN( year ) NE '4'.
error = 'X'.
WRITE : 'Invalid date format.'.
ELSE.
daymonth1 = daymonth.
CONDENSE daymonth1 NO-GAPS.
_len = STRLEN( _daymonth1 ).
l_len = 13 - len.
SHIFT daymonth1 RIGHT BY len PLACES.
CONDENSE daymonth1 NO-GAPS.
month = daymonth1.
CONDENSE month NO-GAPS.
SORT t_month BY monthltx.
READ TABLE t_month WITH KEY monthltx = month.
IF sy-subrc <> 0.
error = 'X'.
WRITE : 'Invalid date format.' .
ELSE.
len = STRLEN( month ).
CONDENSE daymonth NO-GAPS.
SHIFT daymonth LEFT BY len PLACES.
day = daymonth.
CONDENSE day NO-GAPS.
CONCATENATE year t_month-monthnumber day INTO o_date.
ENDIF.
ENDIF.
ELSEIF p_date3 EQ 'X'. "The date format is like 31 apr, 2007
CONDENSE temp_date NO-GAPS.
SPLIT i_date AT ',' INTO daymonth year.
IF STRLEN( year ) NE '4'.
error = 'X'.
WRITE : 'Invalid date format.'.
ELSE.
daymonth1 = daymonth.
CONDENSE daymonth1 NO-GAPS.
SHIFT daymonth1 LEFT BY 2 PLACES.
CONDENSE daymonth1 NO-GAPS.
month = daymonth1.
CONDENSE month NO-GAPS.
TRANSLATE month TO UPPER CASE.
SORT t_month BY monthstx.
MOVE month to mon.
READ TABLE t_month WITH KEY monthstx = mon.
IF sy-subrc <> 0.
error = 'X'.
WRITE : 'Invalid date format.' .
ELSE.
CONDENSE daymonth NO-GAPS.
day = daymonth+0(2).
CONDENSE day NO-GAPS.
CONCATENATE year t_month-monthnumber day INTO o_date.
ENDIF.
ENDIF.
ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'. "Date format is like DD.MM.YYYY or DD/MM/YYYY
CONDENSE temp_date NO-GAPS.
IF STRLEN( temp_date ) EQ 10.
o_date0(4) = temp_date6(4).
o_date4(2) = temp_date3(2).
o_date6(2) = temp_date0(2).
ELSE.
error = 'X'.
WRITE : 'Invalid date format.' .
ENDIF.
ENDIF.
IF STRLEN( o_date ) NE '8'.
error = 'X'.
WRITE : 'Invalid date format.'.
ENDIf.
ENDFORM. " f0100_conv_date
Reward if helpful.
Regards,
Harini.S -
How to get system date and time?
Can someone show me a code on how to get system date and time.
Thanks!there is one really easy way to get system time, the api gives a great example of code on this. use gregorian calendar, which you'll find in the api under GregorianCalendar. You only need to create one instance of GC, ie Calendar time = new GregorianCalendar();
you save seconds, minute and hours into int values, so you don't have to access the system time every second, you can create a thread which adds one to the int second value, if oyu see what i mean, for example, i have saved the hours, minutes and seconds as int values;
int hour, minute, second;
i can then create a thread (Thread thread = new Thread(this) and run it like:
Calendar time;
int hour, minute, second;
Thread thread = null;
public MyTime() {
hour= time.get(Calendar.HOUR_OF_DAY);
minute = time.get(Calendar.MINUTE);
second = time.get(Calendar.SECOND);
if(thread == null) {
thread = new Thread(this);
thread.start();
public void run() {
Thread t = Thread.currentThread();
while(thread == t) {
thread.sleep(1000);
second++;
if(second > 59)
minute++;
if(minute>59)
hour++;
formatTime();
public void formatTime() {
second = (second > 59? 0 : second);
minute = (minute > 59? 0 : minute);
hour = (hour > 23? 0 : hour);
System.out.println(hour+":"+minute+":"+second);
public static void main(String[] args) {
new MyTime();
I know this looks like gibberish but it should work. If not, try to fix the problem, i have written from memory really but i guarantee you, this gets the time then every second, simply adds one to the second and then formats time. You can also access the day, month and year then format them using the above code. I don't like giving code since you should really do these things yourself but it is 2:04am, i have nothing better to do and i am not tired so i did you a favour - i have become what i always did not want to, someone ho stays upall night writing code. -
How to get exact date using to_date
Hi all
how to get exact date over there
select TO_DATE(TRUNC(PLLA.CREATION_DATE),'DD-MON-YYYY'),TRUNC(PLLA.CREATION_DATE),round(PLLA.CREATION_DATE),
TO_DATE(round(PLLA.CREATION_DATE),'DD-MON-YYYY'),TO_DATE(PLLA.CREATION_DATE,'DD-MON-YYYY'),PLLA.CREATION_DATE,
TO_DATE(TRUNC(PLLA.CREATION_DATE)),TO_DATE(round(PLLA.CREATION_DATE))
from po_line_locations_all plla.
In one of the plsql program i want to compare the creation date with given date where as creation date is in Timestamp formatHi,
Use trunc or to_char with masking like 'dd/mm/yyyy' format. If this does not solve your problem then do post your sample input and sample output. As I am unable to make out what is your actual problem.
Regards -
How to get Yestuday date?
hI,
How to get yesturday date? in Message mapping. wht function should I use?
regards,
Ansar.Hello ,
Use this code....
import java.text.*;
import java.util.*;
public class DateTest {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
DateFormat fmt = DateFormat.getDateInstance();
for(int i=0; i<30; ++i) {
c.add(Calendar.DAY_OF_MONTH, -1); //back one
System.out.println(fmt.format(c.getTime()));
With Regards,
Sagar -
How to get twiiter data?
How to get twitter data?
For my project I want large amount of twitter tweets. How do I get?//Oauth Keys (Replace with values that are obtained from registering the application
var oauth_consumer_key ="Your API Key";
var oauth_consumer_secret = "Your API Secret Key";
//Token URL
var oauth_url = "https://api.twitter.com/oauth2/token";
var headerFormat = "Basic {0}";
var authHeader = string.Format(headerFormat,
Convert.ToBase64String(Encoding.UTF8.GetBytes(Uri.EscapeDataString(oauth_consumer_key) + ":" +
Uri.EscapeDataString((oauth_consumer_secret)))
var postBody = "grant_type=client_credentials";
ServicePointManager.Expect100Continue = false;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
using (Stream stream = request.GetRequestStream())
byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
stream.Write(content, 0, content.Length);
request.Headers.Add("Accept-Encoding", "gzip");
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
using (var reader = new StreamReader(responseStream))
JavaScriptSerializer js = new JavaScriptSerializer();
var objText =reader.ReadToEnd();
JObject o = JObject.Parse(objText); -
How to get changed data in ALV in Web Dynpro for ABAP
METHOD on_data_check .
DATA:
node_spfli TYPE REF TO if_wd_context_node,
node_sflight TYPE REF TO if_wd_context_node,
itab_sflight2 TYPE if_display_view=>elements_sflight.
node_spfli = wd_context->get_child_node( name = if_display_view=>wdctx_spfli ).
node_sflight = node_spfli->get_child_node( name = if_display_view=>wdctx_sflight ).
CALL METHOD node_sflight->get_static_attributes_table
IMPORTING
table = itab_sflight2.
this code is ..get all data(changed and not changed)
but i want get changed data only, not all data.
how to get changed data?
Edited by: Ki-Joon Seo on Dec 27, 2007 6:04 AMHi,
To get only the changed data in the ALV grid of a WD, you need to capture the "ON_DATA_CHECK" of the ALV grid.
To this please do the following in the ALV initialization of the ALV table settings :
lr_table_settings->set_data_check(
IF_SALV_WD_C_TABLE_SETTINGS=>DATA_CHECK_ON_CELL_EVENT ).
You may also do this:
lr_table_settings->set_data_check( IF_SALV_WD_C_TABLE_SETTINGS=>DATA_CHECK_ON_CHECK_EVENT)
The above two ways would depend on when do you need to check for the changed data. If you want to check the data as soon as it is entered, then use the first method. Else, use the second method.
You need to register an EVENT HANDLER for this event.(You may do this in your VIEW or Component Controller).
In this Event handler, you would find an importing parameter R_PARAM which is a ref type of IF_SALV_WD_TABLE_DATA_CHECK.
The attribute T_MODIFIED_CELLS of this interface IF_SALV_WD_TABLE_DATA_CHECK will contain the modified cells of the ALV with the old & new values.
Maybe you are looking for
-
Canon MF4270 Scanning Function only works once
After my upgrading to 8.1 my canon MF4270 scanning function will only work one time when it is installed. Any subsequent boot (cold or warm) and it fails to work. The software (canon toolbox or windows scan) will just hang indefinitely. Sometimes I
-
Notes or patch for Import/STO pricing Procedure.
Hi All.. I want to copy Import -JIMPORT and STO pricing procedure. I am having RM0000 only. I am in ECC6 but its not there.Can you pls tell me the patch or notes that i have to apply to get the Import pricing procedures. Earliest help will be useful.
-
Raising Functional level - From 2003 to 2008R2
Recently I have completed the AD upgrade from 2003 to 2012. Now all sites have 2012 DCs only. Next i plans to raise the functional level of both Forest and Domain from 2003 t0 2008R2. I want to know the things to take care before doing this upgrade.
-
Installing R12.1.1. on windows 7
Gooday all, Early last week i was able to install R12.1.1 on a window server 2003. This week i plan installing the same version on windows 7 but before i go ahead with my installation, i want to know if R12 is supported on windows 7. Thank you.
-
An error message using DESCRIBE FIELD
DESCRIBE FIELD MAKT-MATNR LENGTH MNR_LNG . that line off code gives me an error message: In Unicode, DESCRIBE LENGTH can only be used with the IN BYTE MODE or IN CHARACTER MODE addition. can anyone else provide me an explanation and solution..t