本文整理汇总了Java中java.text.DateFormat.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormat.getInstance方法的具体用法?Java DateFormat.getInstance怎么用?Java DateFormat.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.DateFormat
的用法示例。
在下文中一共展示了DateFormat.getInstance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFormatInstance
import java.text.DateFormat; //导入方法依赖的package包/类
protected DateFormat createFormatInstance ( final long timeRange )
{
if ( hasFormat () )
{
try
{
return new SimpleDateFormat ( this.format );
}
catch ( final IllegalArgumentException e )
{
return DateFormat.getInstance ();
}
}
else
{
return Helper.makeFormat ( timeRange );
}
}
示例2: verifyTheProperties
import java.text.DateFormat; //导入方法依赖的package包/类
private void verifyTheProperties(PropertySet propertySet) {
DateFormat df = DateFormat.getInstance();
assertEquals(true, propertySet.getBoolean("testBoolean"));
assertEquals(new String("value1".getBytes()), new String(propertySet.getData("testData")));
assertEquals(df.format(now), df.format(propertySet.getDate("testDate")));
assertEquals(10.245, propertySet.getDouble("testDouble"), 0);
assertEquals(7, propertySet.getInt("testInt"));
assertEquals(100000, propertySet.getLong("testLong"));
assertEquals(new TestObject(1), propertySet.getObject("testObject"));
assertEquals(embeddedProps, propertySet.getProperties("testProperties"));
assertEquals("value1", propertySet.getString("testString"));
assertEquals(TEXT_VALUE, propertySet.getText("testText"));
assertNotNull(propertySet.getXML("testXml"));
}
示例3: testSerialization
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
StandardCategoryLabelGenerator g1 = new StandardCategoryLabelGenerator(
"{2}", DateFormat.getInstance()
);
StandardCategoryLabelGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
g2 = (StandardCategoryLabelGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
示例4: testSerialization
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
IntervalCategoryLabelGenerator g1
= new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
IntervalCategoryLabelGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
g2 = (IntervalCategoryLabelGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
示例5: getDate
import java.text.DateFormat; //导入方法依赖的package包/类
public static String getDate(int type, String t) {
String resultValue = "";
try {
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, type);
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();
df.applyPattern(t);
resultValue = df.format(ca.getTime());
} catch (Exception e) {
Log.i("Logger", "e getDate");
}
return resultValue;
}
示例6: setDate
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Initialise la date
*/
public void setDate(String cs)
{
DateFormat df = DateFormat.getInstance() ;
Date date ;
try
{
date = df.parse(cs);
calendar.setTime(date);
}
catch (ParseException e)
{
e.printStackTrace();
}
}
示例7: execute
import java.text.DateFormat; //导入方法依赖的package包/类
@Override
public int execute(MapleClient c, String[] splitted) {
if (splitted.length < 4) {
c.getPlayer().dropMessage(6, "Tempban [name] [REASON] [hours]");
StringBuilder s = new StringBuilder("Tempban reasons: ");
for (int i = 0; i < types.length; i++) {
s.append(i + 1).append(" - ").append(types[i]).append(", ");
}
c.getPlayer().dropMessage(6, s.toString());
return 0;
}
final MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
final int reason = Integer.parseInt(splitted[2]);
final int numHour = Integer.parseInt(splitted[3]);
final Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, numHour);
final DateFormat df = DateFormat.getInstance();
if (victim == null || reason < 0 || reason >= types.length) {
c.getPlayer().dropMessage(6, "Unable to find character or reason was not valid, type tempban to see reasons");
return 0;
}
victim.tempban("Temp banned by " + c.getPlayer().getName() + " for " + types[reason] + " reason", cal, reason, ipBan);
c.getPlayer().dropMessage(6, "The character " + splitted[1] + " has been successfully tempbanned till " + df.format(cal.getTime()));
return 1;
}
示例8: fileNeedsRefresh
import java.text.DateFormat; //导入方法依赖的package包/类
private boolean fileNeedsRefresh(File f) {
if (f.length() < 1) return true;
if (mCacheTimeOut > 0) {
if ((f.lastModified() + mCacheTimeOut) < System.currentTimeMillis()) {
if (DBG) {
DateFormat fmt = DateFormat.getInstance();
Log.d(TAG, "File " + f.getPath() + " too old f:" + fmt.format(new Date(f.lastModified())) + " now:" + fmt.format(new Date()));
}
return true;
}
}
return false;
}
示例9: showMemoTopics
import java.text.DateFormat; //导入方法依赖的package包/类
private void showMemoTopics(Forum forum, L2PcInstance activeChar, int index)
{
forum.vload();
final StringBuilder html = new StringBuilder(2000);
html.append("<html><body><br><br><table border=0 width=610><tr><td width=10></td><td width=600 align=left><a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsmemo\">Memo Form</a></td></tr></table><img src=\"L2UI.squareblank\" width=\"1\" height=\"10\"><center><table border=0 cellspacing=0 cellpadding=2 bgcolor=888888 width=610><tr><td FIXWIDTH=5></td><td FIXWIDTH=415 align=center>&$413;</td><td FIXWIDTH=120 align=center></td><td FIXWIDTH=70 align=center>&$418;</td></tr></table>");
final DateFormat dateFormat = DateFormat.getInstance();
for (int i = 0, j = getMaxID(forum) + 1; i < (12 * index); j--)
{
if (j < 0)
{
break;
}
final Topic t = forum.getTopic(j);
if (t != null)
{
if (i++ >= (12 * (index - 1)))
{
html.append("<table border=0 cellspacing=0 cellpadding=5 WIDTH=610><tr><td FIXWIDTH=5></td><td FIXWIDTH=415><a action=\"bypass _bbsposts;read;" + forum.getID() + ";" + t.getID() + "\">" + t.getName() + "</a></td><td FIXWIDTH=120 align=center></td><td FIXWIDTH=70 align=center>" + dateFormat.format(new Date(t.getDate())) + "</td></tr></table><img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\">");
}
}
}
html.append("<br><table width=610 cellspace=0 cellpadding=0><tr><td width=50><button value=\"&$422;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"></td><td width=510 align=center><table border=0><tr>");
if (index == 1)
{
html.append("<td><button action=\"\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
}
else
{
html.append("<td><button action=\"bypass _bbstopics;read;" + forum.getID() + ";" + (index - 1) + "\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
}
int nbp = forum.getTopicSize() / 8;
if ((nbp * 8) != ClanTable.getInstance().getClanCount())
{
nbp++;
}
for (int i = 1; i <= nbp; i++)
{
if (i == index)
{
html.append("<td> " + i + " </td>");
}
else
{
html.append("<td><a action=\"bypass _bbstopics;read;" + forum.getID() + ";" + i + "\"> " + i + " </a></td>");
}
}
if (index == nbp)
{
html.append("<td><button action=\"\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
}
else
{
html.append("<td><button action=\"bypass _bbstopics;read;" + forum.getID() + ";" + (index + 1) + "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
}
html.append("</tr></table> </td> <td align=right><button value = \"&$421;\" action=\"bypass _bbstopics;crea;" + forum.getID() + "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td></tr><tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr><tr> <td></td><td align=center><table border=0><tr><td></td><td><edit var = \"Search\" width=130 height=11></td><td><button value=\"&$420;\" action=\"Write 5 -2 0 Search _ _\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td> </tr></table> </td></tr></table><br><br><br></center></body></html>");
CommunityBoardHandler.separateAndSend(html.toString(), activeChar);
}
示例10: HighLowItemLabelGenerator
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Creates an item label generator using the default date and number formats.
*/
public HighLowItemLabelGenerator() {
this(DateFormat.getInstance(), NumberFormat.getInstance());
}
示例11: getTimeSeriesInstance
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Returns a tool tip generator that formats the x-values as dates and the
* y-values as numbers.
*
* @return A tool tip generator (never <code>null</code>).
*/
public static StandardXYToolTipGenerator getTimeSeriesInstance() {
return new StandardXYToolTipGenerator(
DEFAULT_TOOL_TIP_FORMAT, DateFormat.getInstance(), NumberFormat.getInstance()
);
}
示例12: getTimeSeriesInstance
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Returns a tool tip generator that formats the x-values as dates and the
* y-values as numbers.
*
* @return A tool tip generator (never <code>null</code>).
*/
public static StandardXYToolTipGenerator getTimeSeriesInstance() {
return new StandardXYToolTipGenerator(DEFAULT_TOOL_TIP_FORMAT,
DateFormat.getInstance(), NumberFormat.getInstance());
}
示例13: HighLowItemLabelGenerator
import java.text.DateFormat; //导入方法依赖的package包/类
/**
* Creates an item label generator using the default date and number
* formats.
*/
public HighLowItemLabelGenerator() {
this(DateFormat.getInstance(), NumberFormat.getInstance());
}