File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Other Open Source APIs
HowTo use DateFormat static field constants ?
Joined: Apr 16, 2004
Nov 30, 2008 10:32:00
How are the static fields of
)such as DAY_OF_YEAR intended to be used (example please)? Could I use it to build a Julian date ?
public static final int DAY_OF_YEAR_FIELD Useful constant for DAY_OF_YEAR field alignment. Used in FieldPosition of date/time formatting.
Joined: May 27, 2008
Nov 30, 2008 15:49:00
DAY_OF_YEAR_FIELD, etc., can be used to return the position at which a data field was formatted. DAY_OF_YEAR_FIELD is
's %D, which is not very common. For YEAR_FIELD:
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); FieldPosition posn = new FieldPosition(DateFormat.YEAR_FIELD); StringBuffer sb = new StringBuffer(); fmt.format(new Date(), sb, posn); sb.replace(posn.getBeginIndex(), posn.getEndIndex(), "xxxx"); System.out.println(sb);
It doesn't look like this will help with Julian dates.
I agree. Here's the link:
subject: HowTo use DateFormat static field constants ?
How to get tomorrow's date?
Date Converting String to Date
How to derive YYYYMMDD from DAY_IN_YEAR?
datefiled in dd-mm-yyyy format
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015