java.text.SimpleDateFormat.setDateFormatSymbols()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中java.text.SimpleDateFormat.setDateFormatSymbols()方法的一些代码示例,展示了SimpleDateFormat.setDateFormatSymbols()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleDateFormat.setDateFormatSymbols()方法的具体详情如下:
包路径:java.text.SimpleDateFormat
类名称:SimpleDateFormat
方法名:setDateFormatSymbols

SimpleDateFormat.setDateFormatSymbols介绍

[英]Sets the DateFormatSymbols used by this simple date format.
[中]

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Sets the date and time format symbols of this date format.
 *
 * @param newFormatSymbols the new date and time format symbols
 * @throws NullPointerException if the given newFormatSymbols is null
 * @see #getDateFormatSymbols
 */
@Override
public void setDateFormatSymbols( DateFormatSymbols newFormatSymbols ) {
 patternNanosecond = newFormatSymbols.getLocalPatternChars().charAt( PATTERN_MILLISECOND_POSITION );
 super.setDateFormatSymbols( newFormatSymbols );
}

代码示例来源:origin: stackoverflow.com

public class Timeis {
  public static void main(String s[]) {
    long ts = 1022895271767L;
    SimpleDateFormat sdf = new SimpleDateFormat(" MMM d 'at' hh:mm a");
    // CREATE DateFormatSymbols WITH ALL SYMBOLS FROM (DEFAULT) Locale
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
    // OVERRIDE SOME symbols WHILE RETAINING OTHERS
    symbols.setAmPmStrings(new String[] { "am", "pm" });
    sdf.setDateFormatSymbols(symbols);
    String st = sdf.format(ts);
    System.out.println("time is " + st);
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public static String formatDateAsString(Date date) {
  // format date list grid cells
  SimpleDateFormat formatter = new SimpleDateFormat("MMM d, Y @ hh:mma");
  DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
  symbols.setAmPmStrings(new String[] { "am", "pm" });
  formatter.setDateFormatSymbols(symbols);
  return formatter.format(date);
}

代码示例来源:origin: pentaho/pentaho-kettle

String datePattern = pattern;
super.setDateFormatSymbols( formatSymbols );
patternNanosecond = formatSymbols.getLocalPatternChars().charAt( PATTERN_MILLISECOND_POSITION );
StringBuilder sb = new StringBuilder();

代码示例来源:origin: stackoverflow.com

localSimpleDateFormat.get().setDateFormatSymbols(newFormatSymbols);

代码示例来源:origin: pentaho/pentaho-kettle

if ( meta.getFieldFormat()[i] != null ) {
 data.daf.applyPattern( meta.getFieldFormat()[i] );
 data.daf.setDateFormatSymbols( data.dafs );

代码示例来源:origin: pentaho/pentaho-kettle

data.daf.applyPattern( data.defaultDateFormat.toLocalizedPattern() );
 data.daf.setDateFormatSymbols( data.dafs );
 retval = data.daf.format( valueMeta.getDate( valueData ) );
} else {

代码示例来源:origin: stackoverflow.com

Locale russian = new Locale("ru");
String[] newMonths = {
 "января", "февраля", "марта", "апреля", "мая", "июня", 
 "июля", "августа", "сентября", "октября", "ноября", "декабря"};
DateFormatSymbols dfs = DateFormatSymbols.getInstance(russian);
dfs.setMonths(newMonths);
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, russian);
SimpleDateFormat sdf = (SimpleDateFormat) df;
sdf.setDateFormatSymbols(dfs);

Date jud = new SimpleDateFormat("yyyy-MM-dd").parse("2014-02-28");
String month = sdf.format(jud);
System.out.println(month); // output: 28 февраля 2014 г.

代码示例来源:origin: stackoverflow.com

import java.util.*;
import java.text.*;

public class Test {
  public static void main(String[] args) throws Exception {
    String text = "2013-05-23T09:18:07 p.m..380+0000";
    String pattern = "yyyy-MM-dd'T'hh:mm:ss aa'.380+0000'";

    SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
    format.setTimeZone(TimeZone.getTimeZone("UTC"));

    DateFormatSymbols symbols = format.getDateFormatSymbols();
    symbols = (DateFormatSymbols) symbols.clone();
    symbols.setAmPmStrings(new String[] { "a.m.", "p.m."});
    format.setDateFormatSymbols(symbols);

    Date date = format.parse(text);
    System.out.println(date);
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
symbols.setAmPmStrings(new String[] { "am", "pm" });
formatter.setDateFormatSymbols(symbols);

代码示例来源:origin: quickfix-j/quickfixj

protected DateFormat createDateFormat(String format) {
  SimpleDateFormat sdf = new SimpleDateFormat(format);
  sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
  sdf.setDateFormatSymbols(new DateFormatSymbols(Locale.US));
  return sdf;
}

代码示例来源:origin: org.objectstyle.cayenne/cayenne

public Format create(Locale locale, Map parameters) {
  String pattern = (String)parameters.get("pattern");
  DateFormatSymbols sym = new DateFormatSymbols(locale);
  SimpleDateFormat format = new SimpleDateFormat();
  format.setDateFormatSymbols(sym);
  if (pattern != null)
   format.applyPattern(pattern);
  return format;
 }
}

代码示例来源:origin: org.quickfixj/quickfixj-all

protected DateFormat createDateFormat(String format) {
  SimpleDateFormat sdf = new SimpleDateFormat(format);
  sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
  sdf.setDateFormatSymbols(new DateFormatSymbols(Locale.US));
  return sdf;
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

public Format create(Locale locale, Map parameters) {
  String pattern = (String)parameters.get("pattern");
  DateFormatSymbols sym = new DateFormatSymbols(locale);
  SimpleDateFormat format = new SimpleDateFormat();
  format.setDateFormatSymbols(sym);
  if (pattern != null)
   format.applyPattern(pattern);
  return format;
 }
}

代码示例来源:origin: stackoverflow.com

Locale locale = new Locale("el", "GR");
SimpleDateFormat formatter = new SimpleDateFormat("dd MMMM yyyy, HH:mm", locale);
DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);
String[] months = {"Ιανουαρίου", "Φεβρουαρίου", "Μαρτίου", "Απριλίου", "Μαΐου", "Ιουνίου", "Ιουλίου", "Αυγούστου", "Σεπτεμβρίου", "Οκτωβρίου", "Νοεμβρίου", "Δεκεμβρίου"};
dfs.setMonths(months);
formatter.setDateFormatSymbols(dfs);

try {
   System.out.println(formatter.parse("28 Μαρτίου 2014, 14:00"));
   // output in my timezone: Fri Mar 28 14:00:00 CET 2014
} catch (ParseException ex) {
   ex.printStackTrace();
}

代码示例来源:origin: stackoverflow.com

SimpleDateFormat sdf = new SimpleDateFormat("'z dnia' dd MMMM yyyy 'r.'");

DateFormatSymbols dfs = sdf.getDateFormatSymbols();

dfs.setMonths(
  new String[] {
    "stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca",
    "lipca", "sierpnia", "września", "października", "listopada",
    "grudnia"   
  });

sdf.setDateFormatSymbols(dfs);

System.out.println(
  sdf.format(new GregorianCalendar(2012, Calendar.DECEMBER, 28).getTime()));

代码示例来源:origin: stackoverflow.com

SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",
     Locale.GERMAN);
 DateFormatSymbols dfs = df.getDateFormatSymbols();
 String[] swd = {"", "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"};
 dfs.setShortWeekdays(swd);
 df.setDateFormatSymbols(dfs);

代码示例来源:origin: stackoverflow.com

SimpleDateFormat sdf = new SimpleDateFormat(); // uses default locale (here for Germany)
System.out.println(sdf.toPattern()); // dd.MM.yy HH:mm
System.out.println(sdf.toLocalizedPattern()); // tt.MM.uu HH:mm

DateFormatSymbols dfs = DateFormatSymbols.getInstance(Locale.GERMANY);
dfs.setLocalPatternChars("GJMTkHmsSEDFwWahKzZYuXL");
sdf.setDateFormatSymbols(dfs);
sdf.applyLocalizedPattern("TT.MM.JJJJ");

System.out.println(sdf.toPattern()); // dd.MM.yyyy
System.out.println(sdf.toLocalizedPattern()); // TT.MM.JJJJ
System.out.println(sdf.format(new Date())); // 20.06.2016

代码示例来源:origin: stackoverflow.com

String text = "2013-05-23T09:18:07 p.m..380+0000";  
String pattern = "yyyy-MM-dd'T'hh:mm:ss aa'.'SSSZ";
SimpleDateFormat format = new SimpleDateFormat(pattern);

DateFormatSymbols symbols = format.getDateFormatSymbols();
symbols = (DateFormatSymbols) symbols.clone();
symbols.setAmPmStrings(new String[] { "a.m.", "p.m."});
format.setDateFormatSymbols(symbols);

Date date = format.parse(text);
System.out.println(date);

代码示例来源:origin: EvoSuite/evosuite

public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols)
{
  Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, "setDateFormatSymbols", "(Ljava/text/DateFormatSymbols;)V", new Object[] {newFormatSymbols});
  super.setDateFormatSymbols(newFormatSymbols);
  Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, CaptureLog.RETURN_TYPE_VOID);		
}

相关文章

SimpleDateFormat类方法