BF [3075946] - Date problem on non-Christian Yr Locale, i.e.,Buddhist Yr
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3075946&group_id=176962
This commit is contained in:
parent
0fb211b646
commit
962fe09801
|
@ -25,7 +25,10 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -74,7 +77,7 @@ public class GridField
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1124123543602986028L;
|
private static final long serialVersionUID = -6007475135643071025L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field Constructor.
|
* Field Constructor.
|
||||||
|
@ -1358,8 +1361,18 @@ public class GridField
|
||||||
{
|
{
|
||||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value);
|
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value);
|
||||||
}
|
}
|
||||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
|
// BUG:3075946 KTU - Fix Thai Date
|
||||||
m_value==null ? null : m_value.toString().substring(0, m_value.toString().indexOf(".")));
|
//Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
|
||||||
|
// m_value==null ? null : m_value.toString().substring(0, m_value.toString().indexOf(".")));
|
||||||
|
String stringValue = null;
|
||||||
|
if (m_value != null && !m_value.toString().equals("")) {
|
||||||
|
Calendar c1 = Calendar.getInstance();
|
||||||
|
c1.setTime((Date) m_value);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
stringValue = sdf.format(c1.getTime());
|
||||||
|
}
|
||||||
|
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, stringValue);
|
||||||
|
// KTU - Fix Thai Date
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,10 @@ import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -261,9 +263,15 @@ public final class Env
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // JDBC Format 2005-05-09 00:00:00.0
|
{ // JDBC Format 2005-05-09 00:00:00.0
|
||||||
String stringValue = value.toString();
|
// BUG:3075946 KTU, Fix Thai Date
|
||||||
|
//String stringValue = value.toString();
|
||||||
|
String stringValue = "";
|
||||||
|
Calendar c1 = Calendar.getInstance();
|
||||||
|
c1.setTime(value);
|
||||||
|
stringValue = DisplayType.getTimestampFormat_Default().format(c1.getTime());
|
||||||
// Chop off .0 (nanos)
|
// Chop off .0 (nanos)
|
||||||
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
//stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
||||||
|
// KTU
|
||||||
ctx.setProperty(context, stringValue);
|
ctx.setProperty(context, stringValue);
|
||||||
getLogger().finer("Context " + context + "==" + stringValue);
|
getLogger().finer("Context " + context + "==" + stringValue);
|
||||||
}
|
}
|
||||||
|
@ -333,9 +341,15 @@ public final class Env
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // JDBC Format 2005-05-09 00:00:00.0
|
{ // JDBC Format 2005-05-09 00:00:00.0
|
||||||
String stringValue = value.toString();
|
// BUG:3075946 KTU, Fix Thai year
|
||||||
|
//String stringValue = value.toString();
|
||||||
|
String stringValue = "";
|
||||||
|
Calendar c1 = Calendar.getInstance();
|
||||||
|
c1.setTime(value);
|
||||||
|
stringValue = DisplayType.getTimestampFormat_Default().format(c1.getTime());
|
||||||
// Chop off .0 (nanos)
|
// Chop off .0 (nanos)
|
||||||
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
//stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
||||||
|
// KTU
|
||||||
ctx.setProperty(WindowNo+"|"+context, stringValue);
|
ctx.setProperty(WindowNo+"|"+context, stringValue);
|
||||||
getLogger().finer("Context("+WindowNo+") " + context + "==" + stringValue);
|
getLogger().finer("Context("+WindowNo+") " + context + "==" + stringValue);
|
||||||
}
|
}
|
||||||
|
@ -815,13 +829,28 @@ public final class Env
|
||||||
return new Timestamp(System.currentTimeMillis());
|
return new Timestamp(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BUG:3075946 KTU - Fix Thai Date
|
||||||
|
/*
|
||||||
// timestamp requires time
|
// timestamp requires time
|
||||||
if (s.trim().length() == 10)
|
if (s.trim().length() == 10)
|
||||||
s = s.trim() + " 00:00:00.0";
|
s = s.trim() + " 00:00:00.0";
|
||||||
else if (s.indexOf('.') == -1)
|
else if (s.indexOf('.') == -1)
|
||||||
s = s.trim() + ".0";
|
s = s.trim() + ".0";
|
||||||
|
|
||||||
return Timestamp.valueOf(s);
|
return Timestamp.valueOf(s);*/
|
||||||
|
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = DisplayType.getTimestampFormat_Default().parse(s);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timestamp timeStampDate = new Timestamp(date.getTime());
|
||||||
|
|
||||||
|
return timeStampDate;
|
||||||
|
// KTU
|
||||||
} // getContextAsDate
|
} // getContextAsDate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.sql.Time;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -75,7 +74,7 @@ public class Calendar extends CDialog
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -1547404617639717922L;
|
private static final long serialVersionUID = 6482995795697809468L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mimimum Constructor for Date editor
|
* Mimimum Constructor for Date editor
|
||||||
|
@ -115,7 +114,10 @@ public class Calendar extends CDialog
|
||||||
/** Display Type */
|
/** Display Type */
|
||||||
private int m_displayType;
|
private int m_displayType;
|
||||||
/** The Date */
|
/** The Date */
|
||||||
private GregorianCalendar m_calendar;
|
// BUG:3075946KTU - fix Thai Date
|
||||||
|
//private GregorianCalendar m_calendar;
|
||||||
|
private java.util.Calendar m_calendar;
|
||||||
|
// KTU
|
||||||
/** Is there a PM format */
|
/** Is there a PM format */
|
||||||
private boolean m_hasAM_PM = false;
|
private boolean m_hasAM_PM = false;
|
||||||
//
|
//
|
||||||
|
@ -148,7 +150,10 @@ public class Calendar extends CDialog
|
||||||
private CPanel mainPanel = new CPanel();
|
private CPanel mainPanel = new CPanel();
|
||||||
private CPanel monthPanel = new CPanel();
|
private CPanel monthPanel = new CPanel();
|
||||||
private CComboBox cMonth = new CComboBox();
|
private CComboBox cMonth = new CComboBox();
|
||||||
private JSpinner cYear = new JSpinner(new SpinnerNumberModel(2000, 1900,2100,1));
|
// BUG:3075946 KTU - Fix Thai Date
|
||||||
|
//private JSpinner cYear = new JSpinner(new SpinnerNumberModel(2000, 1900,2100,1));
|
||||||
|
private JSpinner cYear = new JSpinner(new SpinnerNumberModel(2000, 1900, 3000, 1));
|
||||||
|
// KTU
|
||||||
private BorderLayout mainLayout = new BorderLayout();
|
private BorderLayout mainLayout = new BorderLayout();
|
||||||
private CPanel dayPanel = new CPanel();
|
private CPanel dayPanel = new CPanel();
|
||||||
private GridLayout dayLayout = new GridLayout();
|
private GridLayout dayLayout = new GridLayout();
|
||||||
|
@ -269,7 +274,10 @@ public class Calendar extends CDialog
|
||||||
*/
|
*/
|
||||||
private void loadData (Timestamp startTS)
|
private void loadData (Timestamp startTS)
|
||||||
{
|
{
|
||||||
m_calendar = new GregorianCalendar(Language.getLoginLanguage().getLocale());
|
// BUG:3075946 KTU - Fix Thai Date
|
||||||
|
//m_calendar = new GregorianCalendar(Language.getLoginLanguage().getLocale());
|
||||||
|
m_calendar = java.util.Calendar.getInstance(Language.getLoginLanguage().getLocale());
|
||||||
|
// KTU
|
||||||
if (startTS == null)
|
if (startTS == null)
|
||||||
m_calendar.setTimeInMillis(System.currentTimeMillis());
|
m_calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue